<!DOCTYPE html>
<html lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="author" content="古 文">



<meta name="description" content="一、概述 ​       因为gstreamer没有提供qnx系统的支持， 因此这里要实现音频和视频的播放，就必须自己实现最终的音视频输出的元件，即sink元件，一开始，我的想法是，可否移植开源的音视频输出库，比如sdl，alsa等等， 但是发现有些麻烦， 反而把事情弄的更复杂了。 最终还是踏踏实实的两个gstreamer的sink元件，用来输出音频和视频。 ​       要编写gstreame">
<meta name="keywords" content="插件,多媒体,gstreamer,qnx,移植">
<meta property="og:type" content="article">
<meta property="og:title" content="gstreamer移植qnx(五)：编写audio sink和video sink插件">
<meta property="og:url" content="http://xuanwolanxue.gitee.io/posts/30680.html">
<meta property="og:site_name" content="同好斋">
<meta property="og:description" content="一、概述 ​       因为gstreamer没有提供qnx系统的支持， 因此这里要实现音频和视频的播放，就必须自己实现最终的音视频输出的元件，即sink元件，一开始，我的想法是，可否移植开源的音视频输出库，比如sdl，alsa等等， 但是发现有些麻烦， 反而把事情弄的更复杂了。 最终还是踏踏实实的两个gstreamer的sink元件，用来输出音频和视频。 ​       要编写gstreame">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-02-21T06:59:08.440Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="gstreamer移植qnx(五)：编写audio sink和video sink插件">
<meta name="twitter:description" content="一、概述 ​       因为gstreamer没有提供qnx系统的支持， 因此这里要实现音频和视频的播放，就必须自己实现最终的音视频输出的元件，即sink元件，一开始，我的想法是，可否移植开源的音视频输出库，比如sdl，alsa等等， 但是发现有些麻烦， 反而把事情弄的更复杂了。 最终还是踏踏实实的两个gstreamer的sink元件，用来输出音频和视频。 ​       要编写gstreame">

<link rel="apple-touch-icon" href="/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="同好斋" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>gstreamer移植qnx(五)：编写audio sink和video sink插件 | 同好斋</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script>
        yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
    </script>



    <script> yiliaConfig.rootUrl = "\/";</script>





    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?778ff23279d4dd12f6287e98750f2d86";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</head></html>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/Minions.jpeg" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">古 文</a></h1>
        </hgroup>

        
        <p class="header-subtitle">同好斋</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="">
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class="no-result">No results found <i class="fa fa-spinner fa-pulse"></i></p>
        


        
		
        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
					<br>
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/categories/">分类</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                            <li><a href="/download/">下载</a></li>
                        
                            <li><a href="/tags/">标签</a></li>
                        
                            <li><a href="/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <br>
                    <br>
                    <br>
                    <br>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:454727014@qq.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" href="https://weibo.com/u/2135682705" title="新浪微博"></a>
                            
                                <a class="fa CSDN" href="https://blog.csdn.net/xuanwolanxue" title="CSDN"></a>
                            
                                <a class="fa 微信" href="/img/微信.jpg" title="微信"></a>
                            
                                <a class="fa 码云" href="https://gitee.com/xuanwolanxue" title="码云"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://pages.github.com/">GitHub</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">喜欢软件，爱好硬件的嵌入式工程师</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">古 文</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/Minions.jpeg" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">古 文</a></h1>
            </hgroup>
            
            <p class="header-subtitle">同好斋</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/categories/">分类</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                    <li><a href="/download/">下载</a></li>
                
                    <li><a href="/tags/">标签</a></li>
                
                    <li><a href="/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:454727014@qq.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" target="_blank" href="https://weibo.com/u/2135682705" title="新浪微博"></a>
                            
                                <a class="fa CSDN" target="_blank" href="https://blog.csdn.net/xuanwolanxue" title="CSDN"></a>
                            
                                <a class="fa 微信" target="_blank" href="/img/微信.jpg" title="微信"></a>
                            
                                <a class="fa 码云" target="_blank" href="https://gitee.com/xuanwolanxue" title="码云"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我">
</nav>
      <div class="body-wrap"><article id="post-多媒体_gstreamer移植qnx(5)编写gstreamer插件audio sink和video sink" class="article article-type-post" itemscope="" itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/posts/30680.html" class="article-date">
      <time datetime="2020-02-20T07:10:12.973Z" itemprop="datePublished">2020-02-20</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      gstreamer移植qnx(五)：编写audio sink和video sink插件
    </h1>
  

        
			<div style="margin-top:10px;">
    <span class="post-time">
      <span class="post-meta-item-icon">
        <i class="fa fa-keyboard-o"></i>
        <span class="post-meta-item-text">  字数统计: </span>
        <span class="post-count">6k 字</span>
      </span>
    </span>

    <span class="post-time">
      &nbsp; | &nbsp;
      <span class="post-meta-item-icon">
        <i class="fa fa-hourglass-half"></i>
        <span class="post-meta-item-text">  阅读时长: </span>
        <span class="post-count">35 分</span>
      </span>
    </span>

    
        <span id="busuanzi_container_page_pv">
          &nbsp; | &nbsp;  本文总阅读量: <span id="busuanzi_value_page_pv"></span> 次
        </span>
    
</div>

        
      </header>
      
      <div class="article-info article-info-post">
        
          <br>
          <br>
        
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/多媒体系列/">多媒体系列</a><a class="article-category-link" href="/categories/多媒体系列/gstreamer移植qnx/">gstreamer移植qnx</a>
    </div>


        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/gstreamer/">gstreamer</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/qnx/">qnx</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/多媒体/">多媒体</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/插件/">插件</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/移植/">移植</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h1>一、概述</h1>
<p>​       因为gstreamer没有提供qnx系统的支持， 因此这里要实现音频和视频的播放，就必须自己实现最终的音视频输出的元件，即sink元件，一开始，我的想法是，可否移植开源的音视频输出库，比如sdl，alsa等等， 但是发现有些麻烦， 反而把事情弄的更复杂了。 最终还是踏踏实实的两个gstreamer的sink元件，用来输出音频和视频。</p>
<p>​       要编写gstreamer的插件有很多方式， 比如直接“继承”实现GstElementClass和GstElement，使用gst-template工具创建一个插件模板，然后去实现。  我这里使用的另一种方式， 既然是实现sink类型的元件。 那么就直接找gstreamer已有的sink元件作为模板，将他们复制过来，删除原有的接口实现代码，换上自己的实现。</p>
<blockquote>
<p><font color="red">注意</font>， 输出的plugin动态库名称以 <a href="http://libpluginname.so" target="_blank" rel="noopener">libpluginname.so</a>  的形式， 而这个pluginname就是 编写插件时，定义插件的宏GST_PLUGIN_DEFINE 的参数中的name， 如果不匹配，就会出现插件无法是使用，被gstreamer将插件加入黑名单</p>
</blockquote>
<a id="more"></a> 
<h1>二、实现QNX audio sink插件</h1>
<p>其实gstreamer有sink插件的“基类”：GstAudioSinkClass，  我们要做的就是继承和override一些接口。GstAudioSinkClass的全部接口如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> _<span class="title">GstAudioSinkClass</span> &#123;</span></span><br><span class="line">  <span class="comment">/**基类，其完成的继承路径是 GSTAudioSinkClass ——&gt; GstAudioBaseSinkClass ——&gt;</span></span><br><span class="line"><span class="comment">   GstBaseSinkClass ——&gt; GstElementClass ,再向上就是和gobject相关的东西了，这里不涉及 */</span>  </span><br><span class="line">  GstAudioBaseSinkClass parent_class; </span><br><span class="line"></span><br><span class="line">  <span class="comment">/* vtable， 接口定义 */</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">/* open the device with given specs， 打开设备*/</span></span><br><span class="line">  gboolean (*open)      (GstAudioSink *sink);</span><br><span class="line">  <span class="comment">/* prepare resources and state to operate with the given specs， 进行prepare操作 */</span></span><br><span class="line">  gboolean (*prepare)   (GstAudioSink *sink, GstAudioRingBufferSpec *spec);</span><br><span class="line">  <span class="comment">/* undo anything that was done in prepare()， 回退到prepare之前 */</span></span><br><span class="line">  gboolean (*unprepare) (GstAudioSink *sink);</span><br><span class="line">  <span class="comment">/* close the device， 关闭设备 */</span></span><br><span class="line">  gboolean (*close)     (GstAudioSink *sink);</span><br><span class="line">  <span class="comment">/* write samples to the device， 向音频设备写数据 */</span></span><br><span class="line">  gint     (*write)     (GstAudioSink *sink, gpointer data, guint length);</span><br><span class="line">  <span class="comment">/* get number of frames queued in the device，获取设备队列里面有多少帧没有输出(即缓存) */</span></span><br><span class="line">  guint    (*delay)     (GstAudioSink *sink);</span><br><span class="line">  <span class="comment">/* reset the audio device, unblock from a write，重置设备 */</span></span><br><span class="line">  <span class="keyword">void</span>     (*reset)     (GstAudioSink *sink);</span><br><span class="line"></span><br><span class="line">  <span class="comment">/*&lt; private &gt;*/</span></span><br><span class="line">  gpointer _gst_reserved[GST_PADDING];</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<p>​        我这里就是以oss音频 sink插件作为模板，将其源码复制出来，删除基于oss接口实现的 gstreamer audio sink接口的代码，然后再填充自己的代码， 其中 头文件 gstQnxAudioSink.h, 其内容如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* GStreamer</span></span><br><span class="line"><span class="comment"> * Copyright (C) gu.wen &lt;454727014@qq.com&gt;</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * gstqnxaudiosink.h: </span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> __GST_QNXAUDIO_H__</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> __GST_QNXAUDIO_H__</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;gst/gst.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;gst/audio/gstaudiosink.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;glib/gtypes.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;sys/asoundlib.h&gt; /** 包含qnx audio接口的头文件 */</span></span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">G_BEGIN_DECLS</span><br><span class="line"><span class="comment">/** 定义方面操作的工具宏 */</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_TYPE_QNXAUDIOSINK (gst_qnxaudio_sink_get_type())</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_QNXAUDIOSINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \</span></span><br><span class="line">                               GST_TYPE_QNXAUDIOSINK, \</span><br><span class="line">                               GstQnxAudioSink))</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_QNXAUDIOSINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \</span></span><br><span class="line">                                       GST_TYPE_QNXAUDIOSINK, \</span><br><span class="line">                                       GstQnxAudioSinkClass))</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_IS_QNXAUDIOSINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \</span></span><br><span class="line">                                  GST_TYPE_QNXAUDIOSINK))</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_IS_QNXAUDIOSINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), \</span></span><br><span class="line">                                          GST_TYPE_QNXAUDIOSINK))</span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> _<span class="title">GstQnxAudioSink</span> <span class="title">GstQnxAudioSink</span>;</span></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> _<span class="title">GstQnxAudioSinkClass</span> <span class="title">GstQnxAudioSinkClass</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">struct</span> _<span class="title">GstQnxAudioSink</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    GstAudioSink sink; <span class="comment">/** 继承audio sink， 这个成员变量必须放在首位 */</span></span><br><span class="line"></span><br><span class="line">    gchar *device;  <span class="comment">/** qnx audio 设备节点的路径 */</span></span><br><span class="line">    gint audioCard; <span class="comment">/** 声卡id */</span></span><br><span class="line">    gint bytes_per_sample; </span><br><span class="line"></span><br><span class="line">    GstCaps *probed_caps;  <span class="comment">/** 存放检索到的caps信息 */</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">/** qnx audio 相关的 数据结构 */</span></span><br><span class="line">    <span class="keyword">snd_pcm_info_t</span> info; </span><br><span class="line">    <span class="keyword">snd_pcm_t</span> *pcm_handle;</span><br><span class="line">    <span class="keyword">snd_pcm_channel_info_t</span> channelInfo;</span><br><span class="line">    <span class="keyword">snd_mixer_t</span> *mixer_handle;</span><br><span class="line">    <span class="keyword">snd_mixer_group_t</span> mixerGroup;</span><br><span class="line">    <span class="keyword">snd_pcm_channel_params_t</span> channelParam;</span><br><span class="line">    <span class="keyword">snd_pcm_channel_setup_t</span> channelSetup;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">struct</span> _<span class="title">GstQnxAudioSinkClass</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">      <span class="comment">/**类，用于定义接口，其完成的继承路径是 </span></span><br><span class="line"><span class="comment">       * _GstQnxAudioSinkClass ——&gt; GSTAudioSinkClass ——&gt; GstAudioBaseSinkClass </span></span><br><span class="line"><span class="comment">       * ——&gt; GstBaseSinkClass ——&gt; GstElementClass</span></span><br><span class="line"><span class="comment">       * 再向上就是和gobject相关的东西了，这里不涉及 </span></span><br><span class="line"><span class="comment">       */</span></span><br><span class="line">    GstAudioSinkClass parent_class;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="comment">/** 获取GType，具体的参考 gobject/glib相关的信息 */</span></span><br><span class="line"><span class="function">GType <span class="title">gst_qnxaudio_sink_get_type</span><span class="params">(<span class="keyword">void</span>)</span></span>;</span><br><span class="line"></span><br><span class="line">G_END_DECLS</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span> <span class="comment">/* __GST_QNXAUDIO_H__ */</span></span></span><br></pre></td></tr></table></figure>
<p>接下来再试重点, qnx audio sink 的实现源文件， 如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br><span class="line">493</span><br><span class="line">494</span><br><span class="line">495</span><br><span class="line">496</span><br><span class="line">497</span><br><span class="line">498</span><br><span class="line">499</span><br><span class="line">500</span><br><span class="line">501</span><br><span class="line">502</span><br><span class="line">503</span><br><span class="line">504</span><br><span class="line">505</span><br><span class="line">506</span><br><span class="line">507</span><br><span class="line">508</span><br><span class="line">509</span><br><span class="line">510</span><br><span class="line">511</span><br><span class="line">512</span><br><span class="line">513</span><br><span class="line">514</span><br><span class="line">515</span><br><span class="line">516</span><br><span class="line">517</span><br><span class="line">518</span><br><span class="line">519</span><br><span class="line">520</span><br><span class="line">521</span><br><span class="line">522</span><br><span class="line">523</span><br><span class="line">524</span><br><span class="line">525</span><br><span class="line">526</span><br><span class="line">527</span><br><span class="line">528</span><br><span class="line">529</span><br><span class="line">530</span><br><span class="line">531</span><br><span class="line">532</span><br><span class="line">533</span><br><span class="line">534</span><br><span class="line">535</span><br><span class="line">536</span><br><span class="line">537</span><br><span class="line">538</span><br><span class="line">539</span><br><span class="line">540</span><br><span class="line">541</span><br><span class="line">542</span><br><span class="line">543</span><br><span class="line">544</span><br><span class="line">545</span><br><span class="line">546</span><br><span class="line">547</span><br><span class="line">548</span><br><span class="line">549</span><br><span class="line">550</span><br><span class="line">551</span><br><span class="line">552</span><br><span class="line">553</span><br><span class="line">554</span><br><span class="line">555</span><br><span class="line">556</span><br><span class="line">557</span><br><span class="line">558</span><br><span class="line">559</span><br><span class="line">560</span><br><span class="line">561</span><br><span class="line">562</span><br><span class="line">563</span><br><span class="line">564</span><br><span class="line">565</span><br><span class="line">566</span><br><span class="line">567</span><br><span class="line">568</span><br><span class="line">569</span><br><span class="line">570</span><br><span class="line">571</span><br><span class="line">572</span><br><span class="line">573</span><br><span class="line">574</span><br><span class="line">575</span><br><span class="line">576</span><br><span class="line">577</span><br><span class="line">578</span><br><span class="line">579</span><br><span class="line">580</span><br><span class="line">581</span><br><span class="line">582</span><br><span class="line">583</span><br><span class="line">584</span><br><span class="line">585</span><br><span class="line">586</span><br><span class="line">587</span><br><span class="line">588</span><br><span class="line">589</span><br><span class="line">590</span><br><span class="line">591</span><br><span class="line">592</span><br><span class="line">593</span><br><span class="line">594</span><br><span class="line">595</span><br><span class="line">596</span><br><span class="line">597</span><br><span class="line">598</span><br><span class="line">599</span><br><span class="line">600</span><br><span class="line">601</span><br><span class="line">602</span><br><span class="line">603</span><br><span class="line">604</span><br><span class="line">605</span><br><span class="line">606</span><br><span class="line">607</span><br><span class="line">608</span><br><span class="line">609</span><br><span class="line">610</span><br><span class="line">611</span><br><span class="line">612</span><br><span class="line">613</span><br><span class="line">614</span><br><span class="line">615</span><br><span class="line">616</span><br><span class="line">617</span><br><span class="line">618</span><br><span class="line">619</span><br><span class="line">620</span><br><span class="line">621</span><br><span class="line">622</span><br><span class="line">623</span><br><span class="line">624</span><br><span class="line">625</span><br><span class="line">626</span><br><span class="line">627</span><br><span class="line">628</span><br><span class="line">629</span><br><span class="line">630</span><br><span class="line">631</span><br><span class="line">632</span><br><span class="line">633</span><br><span class="line">634</span><br><span class="line">635</span><br><span class="line">636</span><br><span class="line">637</span><br><span class="line">638</span><br><span class="line">639</span><br><span class="line">640</span><br><span class="line">641</span><br><span class="line">642</span><br><span class="line">643</span><br><span class="line">644</span><br><span class="line">645</span><br><span class="line">646</span><br><span class="line">647</span><br><span class="line">648</span><br><span class="line">649</span><br><span class="line">650</span><br><span class="line">651</span><br><span class="line">652</span><br><span class="line">653</span><br><span class="line">654</span><br><span class="line">655</span><br><span class="line">656</span><br><span class="line">657</span><br><span class="line">658</span><br><span class="line">659</span><br><span class="line">660</span><br><span class="line">661</span><br><span class="line">662</span><br><span class="line">663</span><br><span class="line">664</span><br><span class="line">665</span><br><span class="line">666</span><br><span class="line">667</span><br><span class="line">668</span><br><span class="line">669</span><br><span class="line">670</span><br><span class="line">671</span><br><span class="line">672</span><br><span class="line">673</span><br><span class="line">674</span><br><span class="line">675</span><br><span class="line">676</span><br><span class="line">677</span><br><span class="line">678</span><br><span class="line">679</span><br><span class="line">680</span><br><span class="line">681</span><br><span class="line">682</span><br><span class="line">683</span><br><span class="line">684</span><br><span class="line">685</span><br><span class="line">686</span><br><span class="line">687</span><br><span class="line">688</span><br><span class="line">689</span><br><span class="line">690</span><br><span class="line">691</span><br><span class="line">692</span><br><span class="line">693</span><br><span class="line">694</span><br><span class="line">695</span><br><span class="line">696</span><br><span class="line">697</span><br><span class="line">698</span><br><span class="line">699</span><br><span class="line">700</span><br><span class="line">701</span><br><span class="line">702</span><br><span class="line">703</span><br><span class="line">704</span><br><span class="line">705</span><br><span class="line">706</span><br><span class="line">707</span><br><span class="line">708</span><br><span class="line">709</span><br><span class="line">710</span><br><span class="line">711</span><br><span class="line">712</span><br><span class="line">713</span><br><span class="line">714</span><br><span class="line">715</span><br><span class="line">716</span><br><span class="line">717</span><br><span class="line">718</span><br><span class="line">719</span><br><span class="line">720</span><br><span class="line">721</span><br><span class="line">722</span><br><span class="line">723</span><br><span class="line">724</span><br><span class="line">725</span><br><span class="line">726</span><br><span class="line">727</span><br><span class="line">728</span><br><span class="line">729</span><br><span class="line">730</span><br><span class="line">731</span><br><span class="line">732</span><br><span class="line">733</span><br><span class="line">734</span><br><span class="line">735</span><br><span class="line">736</span><br><span class="line">737</span><br><span class="line">738</span><br><span class="line">739</span><br><span class="line">740</span><br><span class="line">741</span><br><span class="line">742</span><br><span class="line">743</span><br><span class="line">744</span><br><span class="line">745</span><br><span class="line">746</span><br><span class="line">747</span><br><span class="line">748</span><br><span class="line">749</span><br><span class="line">750</span><br><span class="line">751</span><br><span class="line">752</span><br><span class="line">753</span><br><span class="line">754</span><br><span class="line">755</span><br><span class="line">756</span><br><span class="line">757</span><br><span class="line">758</span><br><span class="line">759</span><br><span class="line">760</span><br><span class="line">761</span><br><span class="line">762</span><br><span class="line">763</span><br><span class="line">764</span><br><span class="line">765</span><br><span class="line">766</span><br><span class="line">767</span><br><span class="line">768</span><br><span class="line">769</span><br><span class="line">770</span><br><span class="line">771</span><br><span class="line">772</span><br><span class="line">773</span><br><span class="line">774</span><br><span class="line">775</span><br><span class="line">776</span><br><span class="line">777</span><br><span class="line">778</span><br><span class="line">779</span><br><span class="line">780</span><br><span class="line">781</span><br><span class="line">782</span><br><span class="line">783</span><br><span class="line">784</span><br><span class="line">785</span><br><span class="line">786</span><br><span class="line">787</span><br><span class="line">788</span><br><span class="line">789</span><br><span class="line">790</span><br><span class="line">791</span><br><span class="line">792</span><br><span class="line">793</span><br><span class="line">794</span><br><span class="line">795</span><br><span class="line">796</span><br><span class="line">797</span><br><span class="line">798</span><br><span class="line">799</span><br><span class="line">800</span><br><span class="line">801</span><br><span class="line">802</span><br><span class="line">803</span><br><span class="line">804</span><br><span class="line">805</span><br><span class="line">806</span><br><span class="line">807</span><br><span class="line">808</span><br><span class="line">809</span><br><span class="line">810</span><br><span class="line">811</span><br><span class="line">812</span><br><span class="line">813</span><br><span class="line">814</span><br><span class="line">815</span><br><span class="line">816</span><br><span class="line">817</span><br><span class="line">818</span><br><span class="line">819</span><br><span class="line">820</span><br><span class="line">821</span><br><span class="line">822</span><br><span class="line">823</span><br><span class="line">824</span><br><span class="line">825</span><br><span class="line">826</span><br><span class="line">827</span><br><span class="line">828</span><br><span class="line">829</span><br><span class="line">830</span><br><span class="line">831</span><br><span class="line">832</span><br><span class="line">833</span><br><span class="line">834</span><br><span class="line">835</span><br><span class="line">836</span><br><span class="line">837</span><br><span class="line">838</span><br><span class="line">839</span><br><span class="line">840</span><br><span class="line">841</span><br><span class="line">842</span><br><span class="line">843</span><br><span class="line">844</span><br><span class="line">845</span><br><span class="line">846</span><br><span class="line">847</span><br><span class="line">848</span><br><span class="line">849</span><br><span class="line">850</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* GStreamer</span></span><br><span class="line"><span class="comment"> * Copyright (C) gu.wen &lt;454727014@qq.com&gt;</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * gstqnxaudiosink.c: </span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * SECTION:element-qnxaudio</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * This element lets you output sound using the qnx audio system (QNXAUDIO).</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * Note that you should almost always use generic audio conversion elements</span></span><br><span class="line"><span class="comment"> * like audioconvert and audioresample in front of an audiosink to make sure</span></span><br><span class="line"><span class="comment"> * your pipeline works under all circumstances (those conversion elements will</span></span><br><span class="line"><span class="comment"> * act in passthrough-mode if no conversion is necessary).</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * &lt;refsect2&gt;</span></span><br><span class="line"><span class="comment"> * &lt;title&gt;Example pipelines&lt;/title&gt;</span></span><br><span class="line"><span class="comment"> * |[</span></span><br><span class="line"><span class="comment"> * gst-launch-1.0 -v audiotestsrc ! audioconvert ! volume volume=0.1 ! qnxaudio</span></span><br><span class="line"><span class="comment"> * ]| will output a sine wave (continuous beep sound) to your sound card (with</span></span><br><span class="line"><span class="comment"> * a very low volume as precaution).</span></span><br><span class="line"><span class="comment"> * |[</span></span><br><span class="line"><span class="comment"> * gst-launch-1.0 -v filesrc location=music.ogg ! decodebin ! audioconvert ! audioresample ! qnxaudio</span></span><br><span class="line"><span class="comment"> * ]| will play an Ogg/Vorbis audio file and output it using the Open Sound System.</span></span><br><span class="line"><span class="comment"> * &lt;/refsect2&gt;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifdef</span> HAVE_CONFIG_H</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"config.h"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;errno.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;unistd.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"gstQnxAudioSink.h"</span></span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> PLUGIN_VERSION <span class="meta-string">"00.01.00"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> PACKAGE <span class="meta-string">"gst-plugins-qnx"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_LICENSE <span class="meta-string">"LGPL"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_PACKAGE_NAME <span class="meta-string">"GStreamer qnx Plug-ins source release"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_PACKAGE_ORIGIN <span class="meta-string">"Unknown package origin"</span></span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">GST_DEBUG_CATEGORY_EXTERN(qnxaudio_debug);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_CAT_DEFAULT qnxaudio_debug</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_dispose</span><span class="params">(GObject *object)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_finalise</span><span class="params">(GObject *object)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_get_property</span><span class="params">(GObject *object, guint prop_id,</span></span></span><br><span class="line"><span class="function"><span class="params">                                           GValue *value, GParamSpec *pspec)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_set_property</span><span class="params">(GObject *object, guint prop_id,</span></span></span><br><span class="line"><span class="function"><span class="params">                                           <span class="keyword">const</span> GValue *value, GParamSpec *pspec)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> GstCaps *<span class="title">gst_qnxaudio_sink_getcaps</span><span class="params">(GstBaseSink *bsink, GstCaps *filter)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxaudio_sink_open</span><span class="params">(GstAudioSink *asink)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxaudio_sink_close</span><span class="params">(GstAudioSink *asink)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxaudio_sink_prepare</span><span class="params">(GstAudioSink *asink,</span></span></span><br><span class="line"><span class="function"><span class="params">                                          GstAudioRingBufferSpec *spec)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxaudio_sink_unprepare</span><span class="params">(GstAudioSink *asink)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> gint <span class="title">gst_qnxaudio_sink_write</span><span class="params">(GstAudioSink *asink, gpointer data,</span></span></span><br><span class="line"><span class="function"><span class="params">                                    guint length)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> guint <span class="title">gst_qnxaudio_sink_delay</span><span class="params">(GstAudioSink *asink)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_reset</span><span class="params">(GstAudioSink *asink)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">/* QnxAudioSink signals and args */</span></span><br><span class="line"><span class="keyword">enum</span></span><br><span class="line">&#123;</span><br><span class="line">    LAST_SIGNAL</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> DEFAULT_DEVICE <span class="meta-string">"/dev/snd/pcmPreferredp"</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">enum</span></span><br><span class="line">&#123;</span><br><span class="line">    PROP_0,</span><br><span class="line">    PROP_DEVICE,</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> FORMATS <span class="meta-string">"&#123;"</span> GST_AUDIO_NE(S16) <span class="meta-string">","</span> GST_AUDIO_NE(U16) <span class="meta-string">", S8, U8 &#125;"</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">/** 定义 固定pad的工厂 */</span></span><br><span class="line"><span class="keyword">static</span> GstStaticPadTemplate qnxaudio_sink_factory =</span><br><span class="line">    GST_STATIC_PAD_TEMPLATE(<span class="string">"sink"</span>,</span><br><span class="line">                            GST_PAD_SINK,</span><br><span class="line">                            GST_PAD_ALWAYS,</span><br><span class="line">                            GST_STATIC_CAPS(<span class="string">"audio/x-raw, "</span></span><br><span class="line">                                            <span class="string">"format = (string) "</span> FORMATS <span class="string">", "</span></span><br><span class="line">                                            <span class="string">"layout = (string) interleaved, "</span></span><br><span class="line">                                            <span class="string">"rate = (int) [ 1, MAX ], "</span></span><br><span class="line">                                            <span class="string">"channels = (int) 1; "</span></span><br><span class="line">                                            <span class="string">"audio/x-raw, "</span></span><br><span class="line">                                            <span class="string">"format = (string) "</span> FORMATS <span class="string">", "</span></span><br><span class="line">                                            <span class="string">"layout = (string) interleaved, "</span></span><br><span class="line">                                            <span class="string">"rate = (int) [ 1, MAX ], "</span></span><br><span class="line">                                            <span class="string">"channels = (int) 2, "</span></span><br><span class="line">                                            <span class="string">"channel-mask = (bitmask) 0x3"</span>));</span><br><span class="line"></span><br><span class="line"><span class="comment">/* static guint gst_qnxaudio_sink_signals[LAST_SIGNAL] = &#123; 0 &#125;; */</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> gst_qnxaudio_sink_parent_class parent_class</span></span><br><span class="line"></span><br><span class="line">G_DEFINE_TYPE(GstQnxAudioSink, gst_qnxaudio_sink, GST_TYPE_AUDIO_SINK);</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_dispose</span><span class="params">(GObject *object)</span></span></span><br><span class="line"><span class="function"></span>&#123;   <span class="comment">/** override GObjectClass 的dispose接口 */</span></span><br><span class="line">    GstQnxAudioSink *qnxaudio = GST_QNXAUDIOSINK(object);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (qnxaudio-&gt;probed_caps)</span><br><span class="line">    &#123;<span class="comment">/**如果已经索引过qnx audio sink 的能力， 就是放已有的caps信息 */</span></span><br><span class="line">        gst_caps_unref(qnxaudio-&gt;probed_caps);</span><br><span class="line">        qnxaudio-&gt;probed_caps = <span class="literal">NULL</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/** 再调用父类的dispose接口 */</span></span><br><span class="line">    G_OBJECT_CLASS(parent_class)-&gt;dispose(object);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> GstStructure *</span><br><span class="line">gst_qnxaudio_helper_get_format_structure(<span class="keyword">unsigned</span> <span class="keyword">int</span> format_bit)</span><br><span class="line">&#123;<span class="comment">/** 根据qnx audio的类型生成caps信息的结构体 */</span></span><br><span class="line">    GstStructure *structure;</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">const</span> gchar *format;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">switch</span> (format_bit)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> SND_PCM_SFMT_U8:</span><br><span class="line">        format = <span class="string">"U8"</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SND_PCM_SFMT_S16_LE:</span><br><span class="line">        format = <span class="string">"S16LE"</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SND_PCM_SFMT_S16_BE:</span><br><span class="line">        format = <span class="string">"S16BE"</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SND_PCM_SFMT_S8:</span><br><span class="line">        format = <span class="string">"S8"</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SND_PCM_SFMT_U16_LE:</span><br><span class="line">        format = <span class="string">"U16LE"</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> SND_PCM_SFMT_U16_BE:</span><br><span class="line">        format = <span class="string">"U16BE"</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">default</span>:</span><br><span class="line">        g_assert_not_reached();</span><br><span class="line">        <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">        <span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:format: %s\n"</span>, __FUNCTION__, __LINE__, format);</span><br><span class="line"></span><br><span class="line">    structure = gst_structure_new(<span class="string">"audio/x-raw"</span>,</span><br><span class="line">                                  <span class="string">"format"</span>, G_TYPE_STRING, format,</span><br><span class="line">                                  <span class="string">"layout"</span>, G_TYPE_STRING, <span class="string">"interleaved"</span>, <span class="literal">NULL</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> structure;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> GstCaps *</span><br><span class="line">gst_qnxaudio_helper_probe_caps(<span class="keyword">snd_pcm_channel_info_t</span> *channelInfo)</span><br><span class="line">&#123;<span class="comment">/** 索引qnx audio的能力信息 */</span></span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> G_BYTE_ORDER == G_LITTLE_ENDIAN</span></span><br><span class="line">    <span class="keyword">const</span> guint probe_formats[] = </span><br><span class="line">    &#123;SND_PCM_SFMT_S16_LE, SND_PCM_SFMT_U16_LE, SND_PCM_SFMT_U8, SND_PCM_SFMT_S8&#125;;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span></span></span><br><span class="line">    <span class="keyword">const</span> guint probe_formats[] = </span><br><span class="line">    &#123;SND_PCM_SFMT_S16_BE, SND_PCM_SFMT_U16_BE, SND_PCM_SFMT_U8, SND_PCM_SFMT_S8&#125;;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">    GstStructure *structure;</span><br><span class="line">    GstCaps *caps;</span><br><span class="line">    <span class="keyword">int</span> f;</span><br><span class="line">    <span class="comment">/* FIXME test make sure we're not currently playing */</span></span><br><span class="line">    <span class="comment">/* FIXME test both mono and stereo */</span></span><br><span class="line"></span><br><span class="line">    caps = gst_caps_new_empty();</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* assume that the most significant bit of format_mask is 0 */</span></span><br><span class="line">    <span class="keyword">for</span> (f = <span class="number">0</span>; f &lt; G_N_ELEMENTS(probe_formats); ++f)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:idx:%d, rate range(%d - %d)\n"</span>, </span><br><span class="line">               __FUNCTION__, __LINE__, f, </span><br><span class="line">               channelInfo-&gt;min_rate, channelInfo-&gt;max_rate);</span><br><span class="line">        </span><br><span class="line">        GValue rate_value = &#123;<span class="number">0</span>&#125;;</span><br><span class="line">        <span class="comment">/* one big range */</span></span><br><span class="line">        g_value_init(&amp;rate_value, GST_TYPE_INT_RANGE);</span><br><span class="line">        gst_value_set_int_range(&amp;rate_value, channelInfo-&gt;min_rate,</span><br><span class="line">                                (channelInfo-&gt;max_rate == <span class="number">-1</span>) ? </span><br><span class="line">                                channelInfo-&gt;min_rate : </span><br><span class="line">                                channelInfo-&gt;max_rate);</span><br><span class="line"></span><br><span class="line">        structure = gst_qnxaudio_helper_get_format_structure(probe_formats[f]);</span><br><span class="line">        gst_structure_set(structure, <span class="string">"channels"</span>, </span><br><span class="line">                          GST_TYPE_INT_RANGE, <span class="number">1</span>, <span class="number">2</span>, <span class="literal">NULL</span>);</span><br><span class="line">        </span><br><span class="line">        gst_structure_set_value(structure, <span class="string">"rate"</span>, &amp;rate_value);</span><br><span class="line">        g_value_unset(&amp;rate_value);</span><br><span class="line"></span><br><span class="line">        gst_caps_append_structure(caps, structure);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (gst_caps_is_empty(caps))</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">/* fixme: make user-visible */</span></span><br><span class="line">        GST_WARNING(<span class="string">"Your qnx audio device could not be probed correctly"</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">        caps = gst_caps_simplify(caps);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:probed caps: %p\n"</span>, </span><br><span class="line">           __FUNCTION__, __LINE__, caps);</span><br><span class="line">    </span><br><span class="line">    GST_DEBUG(<span class="string">"probed caps: %"</span> GST_PTR_FORMAT, caps);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> caps;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_class_init</span><span class="params">(GstQnxAudioSinkClass *klass)</span></span></span><br><span class="line"><span class="function"></span>&#123;<span class="comment">/** 类初始化接口 */</span></span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    GObjectClass *gobject_class;</span><br><span class="line">    GstElementClass *gstelement_class;</span><br><span class="line">    GstBaseSinkClass *gstbasesink_class;</span><br><span class="line">    GstAudioSinkClass *gstaudiosink_class;</span><br><span class="line"></span><br><span class="line">    gobject_class = (GObjectClass *)klass;</span><br><span class="line">    gstelement_class = (GstElementClass *)klass;</span><br><span class="line">    gstbasesink_class = (GstBaseSinkClass *)klass;</span><br><span class="line">    gstaudiosink_class = (GstAudioSinkClass *)klass;</span><br><span class="line"></span><br><span class="line">    parent_class = g_type_class_peek_parent(klass);</span><br><span class="line"></span><br><span class="line">    <span class="comment">/** override 父类接口 */</span></span><br><span class="line">    gobject_class-&gt;dispose = gst_qnxaudio_sink_dispose;</span><br><span class="line">    gobject_class-&gt;finalize = gst_qnxaudio_sink_finalise;</span><br><span class="line">    gobject_class-&gt;get_property = gst_qnxaudio_sink_get_property;</span><br><span class="line">    gobject_class-&gt;set_property = gst_qnxaudio_sink_set_property;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/** 安装属性接口 */</span></span><br><span class="line">    g_object_class_install_property(gobject_class, PROP_DEVICE,</span><br><span class="line">              g_param_spec_string(<span class="string">"device"</span>, <span class="string">"Device"</span>,</span><br><span class="line">                         		  <span class="string">"QNXAUDIO device (usually /dev/dspN)"</span>, </span><br><span class="line">                                  DEFAULT_DEVICE,</span><br><span class="line">                                  G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line"></span><br><span class="line">    <span class="comment">/** override 父类接口 */</span></span><br><span class="line">    gstbasesink_class-&gt;get_caps = GST_DEBUG_FUNCPTR(gst_qnxaudio_sink_getcaps);</span><br><span class="line">    gstaudiosink_class-&gt;open = GST_DEBUG_FUNCPTR(gst_qnxaudio_sink_open);</span><br><span class="line">    gstaudiosink_class-&gt;close = GST_DEBUG_FUNCPTR(gst_qnxaudio_sink_close);</span><br><span class="line">    gstaudiosink_class-&gt;prepare = GST_DEBUG_FUNCPTR(gst_qnxaudio_sink_prepare);</span><br><span class="line">    gstaudiosink_class-&gt;unprepare = GST_DEBUG_FUNCPTR(gst_qnxaudio_sink_unprepare);</span><br><span class="line">    gstaudiosink_class-&gt;write = GST_DEBUG_FUNCPTR(gst_qnxaudio_sink_write);</span><br><span class="line">    gstaudiosink_class-&gt;delay = GST_DEBUG_FUNCPTR(gst_qnxaudio_sink_delay);</span><br><span class="line">    gstaudiosink_class-&gt;reset = GST_DEBUG_FUNCPTR(gst_qnxaudio_sink_reset);</span><br><span class="line"></span><br><span class="line">    <span class="comment">/** 设置qnx  audio sink 元件的meta信息 */</span></span><br><span class="line">    gst_element_class_set_static_metadata(gstelement_class, </span><br><span class="line">                                          <span class="string">"Audio Sink (QNXAUDIO)"</span>,</span><br><span class="line">                                          <span class="string">"Sink/Audio"</span>,</span><br><span class="line">                                          <span class="string">"Output to a sound card via QNXAUDIO"</span>,</span><br><span class="line">                                          <span class="string">"guwen &lt;454727014@qq.com&gt;"</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">/** 添加固定pad工厂 */</span></span><br><span class="line">    gst_element_class_add_static_pad_template(gstelement_class,</span><br><span class="line">                                              &amp;qnxaudio_sink_factory);</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);                                              </span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_init</span><span class="params">(GstQnxAudioSink *qnxaudio)</span></span></span><br><span class="line"><span class="function"></span>&#123;<span class="comment">/** qnx audio sink数据结构初始化 */</span></span><br><span class="line">    GST_DEBUG_OBJECT(qnxaudio, <span class="string">"initializing qnxaudio"</span>);</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    qnxaudio-&gt;pcm_handle = <span class="literal">NULL</span>;</span><br><span class="line">    qnxaudio-&gt;mixer_handle = <span class="literal">NULL</span>;</span><br><span class="line">    qnxaudio-&gt;audioCard = <span class="number">-1</span>;</span><br><span class="line">    qnxaudio-&gt;probed_caps = <span class="literal">NULL</span>;</span><br><span class="line">    qnxaudio-&gt;device = strdup(DEFAULT_DEVICE);</span><br><span class="line">    <span class="built_in">memset</span>(&amp;qnxaudio-&gt;channelInfo, <span class="number">0</span>, <span class="keyword">sizeof</span>(qnxaudio-&gt;channelInfo));</span><br><span class="line">    <span class="built_in">memset</span>(&amp;qnxaudio-&gt;channelParam, <span class="number">0</span>, <span class="keyword">sizeof</span>(qnxaudio-&gt;channelParam));</span><br><span class="line">    <span class="built_in">memset</span>(&amp;qnxaudio-&gt;channelSetup, <span class="number">0</span>, <span class="keyword">sizeof</span>(qnxaudio-&gt;channelSetup));</span><br><span class="line">    <span class="built_in">memset</span>(&amp;qnxaudio-&gt;mixerGroup, <span class="number">0</span>, <span class="keyword">sizeof</span>(qnxaudio-&gt;mixerGroup));</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_finalise</span><span class="params">(GObject *object)</span></span></span><br><span class="line"><span class="function"></span>&#123;<span class="comment">/** override finalise接口 */</span></span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    GstQnxAudioSink *qnxaudio = GST_QNXAUDIOSINK(object);</span><br><span class="line"></span><br><span class="line">    g_free(qnxaudio-&gt;device);</span><br><span class="line"></span><br><span class="line">    G_OBJECT_CLASS(parent_class)-&gt;finalize((GObject *)(object));</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> <span class="keyword">void</span> </span><br><span class="line">gst_qnxaudio_sink_set_property(GObject *object, guint prop_id,</span><br><span class="line">                               <span class="keyword">const</span> GValue *value, GParamSpec *pspec)</span><br><span class="line">&#123;<span class="comment">/** 设置属性 */</span></span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    GstQnxAudioSink *sink;</span><br><span class="line"></span><br><span class="line">    sink = GST_QNXAUDIOSINK(object);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">switch</span> (prop_id)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> PROP_DEVICE:</span><br><span class="line">        <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">        g_free(sink-&gt;device);</span><br><span class="line">        sink-&gt;device = g_value_dup_string(value);</span><br><span class="line">        <span class="keyword">if</span> (sink-&gt;probed_caps)</span><br><span class="line">        &#123;</span><br><span class="line">            gst_caps_unref(sink-&gt;probed_caps);</span><br><span class="line">            sink-&gt;probed_caps = <span class="literal">NULL</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">default</span>:</span><br><span class="line">        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_get_property</span><span class="params">(GObject *object, guint prop_id,</span></span></span><br><span class="line"><span class="function"><span class="params">                                           GValue *value, GParamSpec *pspec)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GstQnxAudioSink *sink;</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line"></span><br><span class="line">    sink = GST_QNXAUDIOSINK(object);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">switch</span> (prop_id)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> PROP_DEVICE:</span><br><span class="line">        g_value_set_string(value, sink-&gt;device);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">default</span>:</span><br><span class="line">        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> GstCaps *<span class="title">gst_qnxaudio_sink_getcaps</span><span class="params">(GstBaseSink *bsink, GstCaps *filter)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GstQnxAudioSink *qnxaudio;    </span><br><span class="line">    GstCaps *caps;</span><br><span class="line">    qnxaudio = GST_QNXAUDIOSINK(bsink);</span><br><span class="line">   <span class="comment">// printf("[%s.%d]===&gt;:pcm_handle: %p\n", </span></span><br><span class="line">   <span class="comment">// __FUNCTION__, __LINE__, qnxaudio-&gt;pcm_handle);</span></span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (qnxaudio-&gt;pcm_handle == <span class="literal">NULL</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">////printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">        caps = gst_pad_get_pad_template_caps(GST_BASE_SINK_PAD(bsink));</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">if</span> (qnxaudio-&gt;probed_caps)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">////printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">        caps = gst_caps_ref(qnxaudio-&gt;probed_caps);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">        caps = gst_qnxaudio_helper_probe_caps(&amp;qnxaudio-&gt;channelInfo);</span><br><span class="line">        <span class="keyword">if</span> (caps &amp;&amp; !gst_caps_is_empty(caps))</span><br><span class="line">        &#123;</span><br><span class="line">            qnxaudio-&gt;probed_caps = gst_caps_ref(caps);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (filter &amp;&amp; caps)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">        GstCaps *intersection;</span><br><span class="line"></span><br><span class="line">        intersection =</span><br><span class="line">            gst_caps_intersect_full(filter, caps, GST_CAPS_INTERSECT_FIRST);</span><br><span class="line">        gst_caps_unref(caps);</span><br><span class="line">        <span class="keyword">return</span> intersection;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">////printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">        <span class="keyword">return</span> caps;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gint <span class="title">ilog2</span><span class="params">(gint x)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">/* well... hacker's delight explains... */</span></span><br><span class="line">    x = x | (x &gt;&gt; <span class="number">1</span>);</span><br><span class="line">    x = x | (x &gt;&gt; <span class="number">2</span>);</span><br><span class="line">    x = x | (x &gt;&gt; <span class="number">4</span>);</span><br><span class="line">    x = x | (x &gt;&gt; <span class="number">8</span>);</span><br><span class="line">    x = x | (x &gt;&gt; <span class="number">16</span>);</span><br><span class="line">    x = x - ((x &gt;&gt; <span class="number">1</span>) &amp; <span class="number">0x55555555</span>);</span><br><span class="line">    x = (x &amp; <span class="number">0x33333333</span>) + ((x &gt;&gt; <span class="number">2</span>) &amp; <span class="number">0x33333333</span>);</span><br><span class="line">    x = (x + (x &gt;&gt; <span class="number">4</span>)) &amp; <span class="number">0x0f0f0f0f</span>;</span><br><span class="line">    x = x + (x &gt;&gt; <span class="number">8</span>);</span><br><span class="line">    x = x + (x &gt;&gt; <span class="number">16</span>);</span><br><span class="line">    <span class="keyword">return</span> (x &amp; <span class="number">0x0000003f</span>) - <span class="number">1</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> gint </span><br><span class="line">gst_qnxaudio_sink_get_format(GstAudioRingBufferFormatType fmt, </span><br><span class="line">                             GstAudioFormat rfmt)</span><br><span class="line">&#123;</span><br><span class="line">    gint result = <span class="number">-1</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">switch</span> (fmt)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MU_LAW:</span><br><span class="line">        result = SND_PCM_SFMT_MU_LAW;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> GST_AUDIO_RING_BUFFER_FORMAT_TYPE_A_LAW:</span><br><span class="line">        result = SND_PCM_SFMT_A_LAW;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IMA_ADPCM:</span><br><span class="line">        result = SND_PCM_SFMT_IMA_ADPCM;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG:</span><br><span class="line">        result = SND_PCM_SFMT_MPEG;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW:</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="keyword">switch</span> (rfmt)</span><br><span class="line">        &#123;</span><br><span class="line">        <span class="keyword">case</span> GST_AUDIO_FORMAT_U8:</span><br><span class="line">            result = SND_PCM_SFMT_U8;</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">case</span> GST_AUDIO_FORMAT_S16LE:</span><br><span class="line">            result = SND_PCM_SFMT_S16_LE;</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">case</span> GST_AUDIO_FORMAT_S16BE:</span><br><span class="line">            result = SND_PCM_SFMT_S16_BE;</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">case</span> GST_AUDIO_FORMAT_S8:</span><br><span class="line">            result = SND_PCM_SFMT_S8;</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">case</span> GST_AUDIO_FORMAT_U16LE:</span><br><span class="line">            result = SND_PCM_SFMT_U16_LE;</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">case</span> GST_AUDIO_FORMAT_U16BE:</span><br><span class="line">            result = SND_PCM_SFMT_U16_BE;</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">default</span>:</span><br><span class="line">            result = <span class="number">-1</span>;</span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">default</span>:</span><br><span class="line">        result = <span class="number">-1</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> result;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxaudio_sink_open</span><span class="params">(GstAudioSink *asink)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    GstQnxAudioSink *qnxaudio;</span><br><span class="line"></span><br><span class="line">    qnxaudio = GST_QNXAUDIOSINK(asink);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">int</span> rtn = snd_pcm_open_name(&amp;qnxaudio-&gt;pcm_handle, </span><br><span class="line">                                qnxaudio-&gt;device, SND_PCM_OPEN_PLAYBACK);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (rtn == EOK)</span><br><span class="line">    &#123;</span><br><span class="line">        rtn = snd_pcm_info(qnxaudio-&gt;pcm_handle, &amp;qnxaudio-&gt;info);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> (rtn == <span class="number">0</span>)</span><br><span class="line">        &#123;</span><br><span class="line"></span><br><span class="line">            qnxaudio-&gt;channelInfo.channel = SND_PCM_CHANNEL_PLAYBACK;</span><br><span class="line">            rtn = snd_pcm_plugin_info(qnxaudio-&gt;pcm_handle, </span><br><span class="line">                                      &amp;qnxaudio-&gt;channelInfo);</span><br><span class="line">            </span><br><span class="line">            <span class="keyword">if</span> (rtn == <span class="number">0</span>)</span><br><span class="line">            &#123;</span><br><span class="line">                qnxaudio-&gt;audioCard = qnxaudio-&gt;info.card;</span><br><span class="line">                <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">                <span class="keyword">return</span> TRUE;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">else</span></span><br><span class="line">            &#123;</span><br><span class="line">                GST_ELEMENT_ERROR(qnxaudio, RESOURCE, OPEN_WRITE, (<span class="literal">NULL</span>),</span><br><span class="line">                                  (<span class="string">"Could not open audio device for playback."</span> </span><br><span class="line">                                   <span class="string">"snd_pcm_plugin_info failed: %s\n"</span>, </span><br><span class="line">                                   snd_strerror(rtn)));</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="comment">/** todo something */</span></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span></span><br><span class="line">        &#123;</span><br><span class="line">            GST_ELEMENT_ERROR(qnxaudio, RESOURCE, OPEN_WRITE,</span><br><span class="line">                              ((<span class="string">"Could not open audio device for playback. "</span></span><br><span class="line">                               <span class="string">"get qnx audio pcm info failedd"</span>)),</span><br><span class="line">                              (<span class="literal">NULL</span>));</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        rtn = snd_pcm_close(qnxaudio-&gt;pcm_handle);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line"></span><br><span class="line">        GST_ERROR_OBJECT(qnxaudio, </span><br><span class="line">                         <span class="string">"open qnx audio output device: %s failed\n"</span>, </span><br><span class="line">                         qnxaudio-&gt;device);</span><br><span class="line"></span><br><span class="line">        <span class="comment">/** Errors */</span></span><br><span class="line">        <span class="keyword">if</span> (rtn == -EINVAL)</span><br><span class="line">        &#123;</span><br><span class="line">            GST_ELEMENT_ERROR(qnxaudio, RESOURCE, OPEN_WRITE,</span><br><span class="line">                              ((<span class="string">"Could not open audio device for playback. "</span></span><br><span class="line">                                <span class="string">"The mode is invalid"</span>)),</span><br><span class="line">                              (<span class="literal">NULL</span>));</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span> (rtn == -ENOENT)</span><br><span class="line">        &#123;</span><br><span class="line">            GST_ELEMENT_ERROR(qnxaudio, RESOURCE, NOT_FOUND,</span><br><span class="line">                              ((<span class="string">"Could not open audio device for playback. "</span></span><br><span class="line">                               <span class="string">"The named device doesn't exist."</span>)),</span><br><span class="line">                              (<span class="literal">NULL</span>));</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span> (rtn == -ENOMEM)</span><br><span class="line">        &#123;</span><br><span class="line">            GST_ELEMENT_ERROR(qnxaudio, RESOURCE, NO_SPACE_LEFT,</span><br><span class="line">                              ((<span class="string">"Could not open audio device for playback. "</span></span><br><span class="line">                                <span class="string">"Not enough memory is available to allocate the"</span></span><br><span class="line">                                <span class="string">"control structures"</span>)),</span><br><span class="line">                              (<span class="literal">NULL</span>));</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span> (rtn == -SND_ERROR_INCOMPATIBLE_VERSION)</span><br><span class="line">        &#123;</span><br><span class="line">            GST_ELEMENT_ERROR(qnxaudio, RESOURCE, OPEN_WRITE,</span><br><span class="line">                              ((<span class="string">"Could not open audio device for playback. "</span></span><br><span class="line">                                <span class="string">"The audio driver version is incompatible "</span></span><br><span class="line">                                <span class="string">"with the client library that the application"</span></span><br><span class="line">                                <span class="string">"is using."</span>)),</span><br><span class="line">                              (<span class="literal">NULL</span>));</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    qnxaudio-&gt;pcm_handle = <span class="literal">NULL</span>;</span><br><span class="line">    qnxaudio-&gt;mixer_handle = <span class="literal">NULL</span>;</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">return</span> FALSE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxaudio_sink_close</span><span class="params">(GstAudioSink *asink)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GstQnxAudioSink *qnxaudio;</span><br><span class="line">    <span class="keyword">int</span> rtn;</span><br><span class="line">    qnxaudio = GST_QNXAUDIOSINK(asink);</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">if</span> (qnxaudio-&gt;pcm_handle)</span><br><span class="line">    &#123;</span><br><span class="line">        rtn = snd_pcm_plugin_flush(qnxaudio-&gt;pcm_handle, </span><br><span class="line">                                   SND_PCM_CHANNEL_PLAYBACK);       </span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (qnxaudio-&gt;mixer_handle)</span><br><span class="line">    &#123;</span><br><span class="line">        rtn = snd_mixer_close(qnxaudio-&gt;mixer_handle);</span><br><span class="line">        <span class="keyword">if</span> (rtn != <span class="number">0</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            GST_ERROR_OBJECT(qnxaudio, <span class="string">"close mixer failed: %d\n"</span>, rtn);</span><br><span class="line">            <span class="keyword">return</span> FALSE;</span><br><span class="line">        &#125;  </span><br><span class="line">        </span><br><span class="line">        qnxaudio-&gt;mixer_handle = <span class="literal">NULL</span>;      </span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (qnxaudio-&gt;pcm_handle)</span><br><span class="line">    &#123;</span><br><span class="line">        rtn = snd_pcm_close(qnxaudio-&gt;pcm_handle);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> (rtn != <span class="number">0</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            GST_ERROR_OBJECT(qnxaudio, </span><br><span class="line">                             <span class="string">"close qnx audio device failed: %d\n"</span>, </span><br><span class="line">                             rtn);</span><br><span class="line">            <span class="keyword">return</span> FALSE;</span><br><span class="line">        &#125;</span><br><span class="line">        qnxaudio-&gt;pcm_handle = <span class="literal">NULL</span>;        </span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">return</span> TRUE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> gboolean </span><br><span class="line">gst_qnxaudio_sink_prepare(GstAudioSink *asink, GstAudioRingBufferSpec *spec)</span><br><span class="line">&#123;</span><br><span class="line">    GstQnxAudioSink *qnxaudio;</span><br><span class="line">    <span class="keyword">int</span> tmp;</span><br><span class="line">    guint mSampleBits, mSampleRate, mSampleChannels;</span><br><span class="line">    gint fragSize;</span><br><span class="line">    <span class="keyword">snd_pcm_channel_params_t</span>* pChParam;</span><br><span class="line"></span><br><span class="line">    qnxaudio = GST_QNXAUDIOSINK(asink);</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line"></span><br><span class="line">    tmp = gst_qnxaudio_sink_get_format(spec-&gt;type,</span><br><span class="line">                                       GST_AUDIO_INFO_FORMAT(&amp;spec-&gt;info));</span><br><span class="line">    <span class="keyword">if</span> (tmp == <span class="number">-1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ELEMENT_ERROR(qnxaudio, RESOURCE, SETTINGS, (<span class="literal">NULL</span>),</span><br><span class="line">                          (<span class="string">"Unable to get format (%d, %d)"</span>, spec-&gt;type,</span><br><span class="line">                           GST_AUDIO_INFO_FORMAT(&amp;spec-&gt;info)));</span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    mSampleBits = GST_AUDIO_INFO_WIDTH(&amp;spec-&gt;info);</span><br><span class="line">    mSampleRate = GST_AUDIO_INFO_RATE(&amp;spec-&gt;info);</span><br><span class="line">    mSampleChannels = GST_AUDIO_INFO_CHANNELS(&amp;spec-&gt;info);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (mSampleBits != <span class="number">16</span> &amp;&amp; mSampleBits != <span class="number">8</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ELEMENT_ERROR(qnxaudio, RESOURCE, SETTINGS, (<span class="literal">NULL</span>),</span><br><span class="line">                          (<span class="string">"unexpected width %d"</span>, mSampleBits));</span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    tmp = ilog2(spec-&gt;segsize);</span><br><span class="line">    tmp = ((spec-&gt;segtotal &amp; <span class="number">0x7fff</span>) &lt;&lt; <span class="number">16</span>) | tmp;</span><br><span class="line">    GST_DEBUG_OBJECT(qnxaudio, <span class="string">"set segsize: %d, segtotal: %d, value: %08x"</span>,</span><br><span class="line">                     spec-&gt;segsize, spec-&gt;segtotal, tmp);</span><br><span class="line"></span><br><span class="line">    fragSize = <span class="number">0</span>;</span><br><span class="line">	</span><br><span class="line">    pChParam = &amp;qnxaudio-&gt;channelParam;</span><br><span class="line">    pChParam-&gt;mode = SND_PCM_MODE_BLOCK;</span><br><span class="line">    pChParam-&gt;channel = SND_PCM_CHANNEL_PLAYBACK;</span><br><span class="line">    pChParam-&gt;start_mode = SND_PCM_START_FULL;</span><br><span class="line">    pChParam-&gt;stop_mode = SND_PCM_STOP_STOP;</span><br><span class="line"></span><br><span class="line">    pChParam-&gt;buf.block.frag_size = </span><br><span class="line">                                qnxaudio-&gt;channelInfo.max_fragment_size;</span><br><span class="line">    <span class="keyword">if</span> (fragSize != <span class="number">-1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        pChParam-&gt;buf.block.frag_size = fragSize;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    pChParam-&gt;buf.block.frags_max = <span class="number">-1</span>; <span class="comment">//num_frags;</span></span><br><span class="line">    pChParam-&gt;buf.block.frags_min = <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">    pChParam-&gt;format.interleave = <span class="number">1</span>;</span><br><span class="line">    pChParam-&gt;format.rate = mSampleRate;</span><br><span class="line">    pChParam-&gt;format.voices = mSampleChannels;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (mSampleBits == <span class="number">8</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        pChParam-&gt;format.format = SND_PCM_SFMT_U8;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">if</span> (mSampleBits == <span class="number">16</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        pChParam-&gt;format.format = SND_PCM_SFMT_S16_LE;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">        pChParam-&gt;format.format = SND_PCM_SFMT_S16_LE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="built_in">strcpy</span>(pChParam-&gt;sw_mixer_subchn_name, <span class="string">"Wave playback channel"</span>);</span><br><span class="line">	tmp = snd_pcm_plugin_params(qnxaudio-&gt;pcm_handle, </span><br><span class="line">                                &amp;qnxaudio-&gt;channelParam);</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (tmp &lt; <span class="number">0</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ELEMENT_ERROR(qnxaudio, RESOURCE, SETTINGS, (<span class="literal">NULL</span>),</span><br><span class="line">                          (<span class="string">"snd_pcm_plugin_params failed: %s\n"</span>,</span><br><span class="line">                           snd_strerror(tmp)));</span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line">	tmp = snd_pcm_plugin_prepare(qnxaudio-&gt;pcm_handle, </span><br><span class="line">                                 SND_PCM_CHANNEL_PLAYBACK);</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (tmp &lt; <span class="number">0</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ELEMENT_ERROR(qnxaudio, RESOURCE, SETTINGS, (<span class="literal">NULL</span>),</span><br><span class="line">                          (<span class="string">"snd_pcm_plugin_prepare failed: %s\n"</span>,</span><br><span class="line">                           snd_strerror(tmp)));</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    qnxaudio-&gt;channelSetup.channel = SND_PCM_CHANNEL_PLAYBACK;</span><br><span class="line">    qnxaudio-&gt;channelSetup.mixer_gid = &amp;qnxaudio-&gt;mixerGroup.gid;</span><br><span class="line">    </span><br><span class="line">	tmp = snd_pcm_plugin_setup(qnxaudio-&gt;pcm_handle, </span><br><span class="line">                               &amp;qnxaudio-&gt;channelSetup);</span><br><span class="line">    <span class="keyword">if</span> (tmp &lt; <span class="number">0</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ELEMENT_ERROR(qnxaudio, RESOURCE, SETTINGS, (<span class="literal">NULL</span>),</span><br><span class="line">                          (<span class="string">"snd_pcm_plugin_setup failed: %s\n"</span>,</span><br><span class="line">                           snd_strerror(tmp)));</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line">    GST_INFO_OBJECT(qnxaudio, <span class="string">"Format %s \n"</span>, </span><br><span class="line">                    snd_pcm_get_format_name(</span><br><span class="line">                        qnxaudio-&gt;channelSetup.format.format));</span><br><span class="line">    </span><br><span class="line">    GST_INFO_OBJECT(qnxaudio, <span class="string">"Frag Size %d \n"</span>, </span><br><span class="line">                    qnxaudio-&gt;channelSetup.buf.block.frag_size);</span><br><span class="line">    </span><br><span class="line">    GST_INFO_OBJECT(qnxaudio, <span class="string">"Total Frags %d \n"</span>, </span><br><span class="line">                    qnxaudio-&gt;channelSetup.buf.block.frags);</span><br><span class="line">    </span><br><span class="line">    GST_INFO_OBJECT(qnxaudio, <span class="string">"Rate %d \n"</span>, </span><br><span class="line">                    qnxaudio-&gt;channelSetup.format.rate);</span><br><span class="line">    </span><br><span class="line">    GST_INFO_OBJECT(qnxaudio, <span class="string">"Voices %d \n"</span>, </span><br><span class="line">                    qnxaudio-&gt;channelSetup.format.voices);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (qnxaudio-&gt;mixerGroup.gid.name[<span class="number">0</span>] == <span class="number">0</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ELEMENT_ERROR(qnxaudio, RESOURCE, SETTINGS, (<span class="literal">NULL</span>),</span><br><span class="line">                          (<span class="string">"Mixer Pcm Group [%s] Not Set \n"</span>,</span><br><span class="line">                           qnxaudio-&gt;mixerGroup.gid.name));</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    tmp = snd_mixer_open(&amp;qnxaudio-&gt;mixer_handle, </span><br><span class="line">                         qnxaudio-&gt;audioCard, </span><br><span class="line">                         qnxaudio-&gt;channelSetup.mixer_device);</span><br><span class="line">    <span class="keyword">if</span> (tmp &lt; <span class="number">0</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ELEMENT_ERROR(qnxaudio, RESOURCE, SETTINGS, (<span class="literal">NULL</span>),</span><br><span class="line">                          (<span class="string">"snd_mixer_open failed: %s\n"</span>,</span><br><span class="line">                           snd_strerror(tmp)));</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    spec-&gt;segsize = pChParam-&gt;buf.block.frag_size;</span><br><span class="line">    <span class="comment">//spec-&gt;segtotal = info.fragstotal;</span></span><br><span class="line"></span><br><span class="line">    qnxaudio-&gt;bytes_per_sample = GST_AUDIO_INFO_BPF(&amp;spec-&gt;info);</span><br><span class="line"></span><br><span class="line">    GST_DEBUG_OBJECT(qnxaudio, <span class="string">"got segsize: %d, segtotal: %d, value: %08x"</span>,</span><br><span class="line">                     spec-&gt;segsize, spec-&gt;segtotal, tmp);</span><br><span class="line"></span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">return</span> TRUE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxaudio_sink_unprepare</span><span class="params">(GstAudioSink *asink)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">if</span> (!gst_qnxaudio_sink_close(asink))</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ERROR_OBJECT(asink, <span class="string">"Could not close the audio device"</span>);</span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (!gst_qnxaudio_sink_open(asink))</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ERROR_OBJECT(asink, <span class="string">"Could not reopen the audio device"</span>);</span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> TRUE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gint <span class="title">gst_qnxaudio_sink_write</span><span class="params">(GstAudioSink *asink, gpointer data, guint length)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">////printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">return</span> snd_pcm_plugin_write(GST_QNXAUDIOSINK(asink)-&gt;pcm_handle, </span><br><span class="line">                                data, length);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> guint <span class="title">gst_qnxaudio_sink_delay</span><span class="params">(GstAudioSink *asink)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GstQnxAudioSink *qnxaudio;</span><br><span class="line">    <span class="comment">////printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">snd_pcm_channel_status_t</span> status;</span><br><span class="line">    <span class="built_in">memset</span>(&amp;status, <span class="number">0</span>, <span class="keyword">sizeof</span>(status));</span><br><span class="line">    status.channel = SND_PCM_CHANNEL_PLAYBACK;</span><br><span class="line">    qnxaudio = GST_QNXAUDIOSINK(asink);</span><br><span class="line">    <span class="keyword">if</span> (snd_pcm_plugin_status(qnxaudio-&gt;pcm_handle, &amp;status) &lt; <span class="number">0</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        GST_ERROR_OBJECT(asink, </span><br><span class="line">                         <span class="string">"underrun: playback channel status error\n"</span>);</span><br><span class="line">        <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> status.count / qnxaudio-&gt;bytes_per_sample;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxaudio_sink_reset</span><span class="params">(GstAudioSink *asink)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="comment">/* There's nothing we can do here really, 对于qnx audio这里没有实现这个接口 */</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">///////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">///////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line">GST_DEBUG_CATEGORY (qnxaudio_debug);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_CAT_DEFAULT qnxaudio_debug</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> gboolean</span><br><span class="line">plugin_init (GstPlugin * plugin)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="comment">/** 注册 qnxaudiosink这个元件 */</span></span><br><span class="line">    <span class="keyword">if</span> (!gst_element_register(plugin, <span class="string">"qnxaudiosink"</span>, GST_RANK_SECONDARY,</span><br><span class="line">                              GST_TYPE_QNXAUDIOSINK))</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    GST_DEBUG_CATEGORY_INIT(qnxaudio_debug, <span class="string">"qnxaudio"</span>, <span class="number">0</span>, <span class="string">"QNX audio elements"</span>);</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifdef</span> ENABLE_NLS</span></span><br><span class="line">    GST_DEBUG(<span class="string">"binding text domain %s to locale dir %s"</span>, GETTEXT_PACKAGE,</span><br><span class="line">              LOCALEDIR);</span><br><span class="line">    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);</span><br><span class="line">    bind_textdomain_codeset(GETTEXT_PACKAGE, <span class="string">"UTF-8"</span>);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span> <span class="comment">/* ENABLE_NLS */</span></span></span><br><span class="line"></span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">return</span> TRUE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,</span><br><span class="line">    GST_VERSION_MINOR,</span><br><span class="line">    qnxaudio,</span><br><span class="line">    <span class="string">"Qnx Audio support for GStreamer"</span>,</span><br><span class="line">    plugin_init, PLUGIN_VERSION, GST_LICENSE, </span><br><span class="line">    GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)</span><br></pre></td></tr></table></figure>
<h1>三、 实现QNX video sink 插件</h1>
<p>和audio sink一样，gstreamer也提供了video sink的“基类”GstVideoSinkClass， 其内容就相对比较简单：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * GstVideoSinkClass:</span></span><br><span class="line"><span class="comment"> * @parent_class: the parent class structure</span></span><br><span class="line"><span class="comment"> * @show_frame: render a video frame. Maps to #GstBaseSinkClass.render() and</span></span><br><span class="line"><span class="comment"> *     #GstBaseSinkClass.preroll() vfuncs. Rendering during preroll will be</span></span><br><span class="line"><span class="comment"> *     suppressed if the #GstVideoSink:show-preroll-frame property is set to</span></span><br><span class="line"><span class="comment"> *     %FALSE.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * The video sink class structure. Derived classes should override the</span></span><br><span class="line"><span class="comment"> * @show_frame virtual function.</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="class"><span class="keyword">struct</span> _<span class="title">GstVideoSinkClass</span> &#123;</span></span><br><span class="line">  GstBaseSinkClass parent_class;</span><br><span class="line"></span><br><span class="line">  GstFlowReturn  (*show_frame) (GstVideoSink *video_sink, GstBuffer *buf);</span><br><span class="line"></span><br><span class="line">  <span class="comment">/*&lt; private &gt;*/</span></span><br><span class="line">  gpointer _gst_reserved[GST_PADDING];</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<p>一样的参考现有的视频输出元件的模板，定义头文件如下：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* GStreamer</span></span><br><span class="line"><span class="comment"> * Copyright (C) gu.wen &lt;454727014@qq.com&gt;</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * gstqnxvideosink.h: </span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> __GST_QNX_VIDEO_SINK_H__</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> __GST_QNX_VIDEO_SINK_H__</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;gst/gst.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;gst/video/video.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;gst/video/gstvideosink.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">//for qnx screen api</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;screen/screen.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">//#include &lt;aalib.h&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifdef</span> __cplusplus</span></span><br><span class="line"><span class="keyword">extern</span> <span class="string">"C"</span></span><br><span class="line">&#123;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span> <span class="comment">/* __cplusplus */</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_TYPE_QNXVIDEOSINK \</span></span><br><span class="line">    (gst_qnxvideo_sink_get_type())</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_QNXVIDEOSINK(obj) \</span></span><br><span class="line">    (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_QNXVIDEOSINK, GstQnxVideoSink))</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_QNXVIDEOSINK_CLASS(klass) \</span></span><br><span class="line">    (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_QNXVIDEOSINK, GstQnxVideoSinkClass))</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_IS_QNXVIDEOSINK(obj) \</span></span><br><span class="line">    (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_QNXVIDEOSINK))</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_IS_QNXVIDEOSINK_CLASS(klass) \</span></span><br><span class="line">    (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_QNXVIDEOSINK))</span><br><span class="line"></span><br><span class="line">    <span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> _<span class="title">GstQnxVideoSink</span> <span class="title">GstQnxVideoSink</span>;</span></span><br><span class="line">    <span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> _<span class="title">GstQnxVideoSinkClass</span> <span class="title">GstQnxVideoSinkClass</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">struct</span> _<span class="title">GstQnxVideoSink</span></span></span><br><span class="line"><span class="class">&#123;</span><span class="comment">/** qnx video sink 继承 自  GstVideoSink */</span></span><br><span class="line">    GstVideoSink parent;</span><br><span class="line"></span><br><span class="line">    GstVideoInfo info;</span><br><span class="line"></span><br><span class="line">    gint frames_displayed;</span><br><span class="line">    guint64 frame_time;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">screen_context_t</span> screen_ctx;</span><br><span class="line">    <span class="keyword">screen_window_t</span> screen_win;</span><br><span class="line">    gboolean isOpened;</span><br><span class="line">    <span class="keyword">screen_buffer_t</span> dispBuf[<span class="number">2</span>];</span><br><span class="line">    gint dispRect[<span class="number">4</span>]; <span class="comment">/** dsiaply rect size */</span></span><br><span class="line">    gint startX;</span><br><span class="line">    gint startY;</span><br><span class="line">    gint width;</span><br><span class="line">    gint height;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">struct</span> _<span class="title">GstQnxVideoSinkClass</span></span></span><br><span class="line"><span class="class">&#123;</span><span class="comment">/** qnx video sink class 继承自 GstVideoSinkClass */</span></span><br><span class="line">    GstVideoSinkClass parent_class;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="function">GType <span class="title">gst_qnxvideo_sink_get_type</span><span class="params">(<span class="keyword">void</span>)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifdef</span> __cplusplus</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span> <span class="comment">/* __cplusplus */</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span> <span class="comment">/* __GST_QNXVIDEOSINKE_H__ */</span></span></span><br></pre></td></tr></table></figure>
<p>接下来就是重点，具体的video sink元件的实现,其代码稍微有点多，具体如下所示。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br><span class="line">493</span><br><span class="line">494</span><br><span class="line">495</span><br><span class="line">496</span><br><span class="line">497</span><br><span class="line">498</span><br><span class="line">499</span><br><span class="line">500</span><br><span class="line">501</span><br><span class="line">502</span><br><span class="line">503</span><br><span class="line">504</span><br><span class="line">505</span><br><span class="line">506</span><br><span class="line">507</span><br><span class="line">508</span><br><span class="line">509</span><br><span class="line">510</span><br><span class="line">511</span><br><span class="line">512</span><br><span class="line">513</span><br><span class="line">514</span><br><span class="line">515</span><br><span class="line">516</span><br><span class="line">517</span><br><span class="line">518</span><br><span class="line">519</span><br><span class="line">520</span><br><span class="line">521</span><br><span class="line">522</span><br><span class="line">523</span><br><span class="line">524</span><br><span class="line">525</span><br><span class="line">526</span><br><span class="line">527</span><br><span class="line">528</span><br><span class="line">529</span><br><span class="line">530</span><br><span class="line">531</span><br><span class="line">532</span><br><span class="line">533</span><br><span class="line">534</span><br><span class="line">535</span><br><span class="line">536</span><br><span class="line">537</span><br><span class="line">538</span><br><span class="line">539</span><br><span class="line">540</span><br><span class="line">541</span><br><span class="line">542</span><br><span class="line">543</span><br><span class="line">544</span><br><span class="line">545</span><br><span class="line">546</span><br><span class="line">547</span><br><span class="line">548</span><br><span class="line">549</span><br><span class="line">550</span><br><span class="line">551</span><br><span class="line">552</span><br><span class="line">553</span><br><span class="line">554</span><br><span class="line">555</span><br><span class="line">556</span><br><span class="line">557</span><br><span class="line">558</span><br><span class="line">559</span><br><span class="line">560</span><br><span class="line">561</span><br><span class="line">562</span><br><span class="line">563</span><br><span class="line">564</span><br><span class="line">565</span><br><span class="line">566</span><br><span class="line">567</span><br><span class="line">568</span><br><span class="line">569</span><br><span class="line">570</span><br><span class="line">571</span><br><span class="line">572</span><br><span class="line">573</span><br><span class="line">574</span><br><span class="line">575</span><br><span class="line">576</span><br><span class="line">577</span><br><span class="line">578</span><br><span class="line">579</span><br><span class="line">580</span><br><span class="line">581</span><br><span class="line">582</span><br><span class="line">583</span><br><span class="line">584</span><br><span class="line">585</span><br><span class="line">586</span><br><span class="line">587</span><br><span class="line">588</span><br><span class="line">589</span><br><span class="line">590</span><br><span class="line">591</span><br><span class="line">592</span><br><span class="line">593</span><br><span class="line">594</span><br><span class="line">595</span><br><span class="line">596</span><br><span class="line">597</span><br><span class="line">598</span><br><span class="line">599</span><br><span class="line">600</span><br><span class="line">601</span><br><span class="line">602</span><br><span class="line">603</span><br><span class="line">604</span><br><span class="line">605</span><br><span class="line">606</span><br><span class="line">607</span><br><span class="line">608</span><br><span class="line">609</span><br><span class="line">610</span><br><span class="line">611</span><br><span class="line">612</span><br><span class="line">613</span><br><span class="line">614</span><br><span class="line">615</span><br><span class="line">616</span><br><span class="line">617</span><br><span class="line">618</span><br><span class="line">619</span><br><span class="line">620</span><br><span class="line">621</span><br><span class="line">622</span><br><span class="line">623</span><br><span class="line">624</span><br><span class="line">625</span><br><span class="line">626</span><br><span class="line">627</span><br><span class="line">628</span><br><span class="line">629</span><br><span class="line">630</span><br><span class="line">631</span><br><span class="line">632</span><br><span class="line">633</span><br><span class="line">634</span><br><span class="line">635</span><br><span class="line">636</span><br><span class="line">637</span><br><span class="line">638</span><br><span class="line">639</span><br><span class="line">640</span><br><span class="line">641</span><br><span class="line">642</span><br><span class="line">643</span><br><span class="line">644</span><br><span class="line">645</span><br><span class="line">646</span><br><span class="line">647</span><br><span class="line">648</span><br><span class="line">649</span><br><span class="line">650</span><br><span class="line">651</span><br><span class="line">652</span><br><span class="line">653</span><br><span class="line">654</span><br><span class="line">655</span><br><span class="line">656</span><br><span class="line">657</span><br><span class="line">658</span><br><span class="line">659</span><br><span class="line">660</span><br><span class="line">661</span><br><span class="line">662</span><br><span class="line">663</span><br><span class="line">664</span><br><span class="line">665</span><br><span class="line">666</span><br><span class="line">667</span><br><span class="line">668</span><br><span class="line">669</span><br><span class="line">670</span><br><span class="line">671</span><br><span class="line">672</span><br><span class="line">673</span><br><span class="line">674</span><br><span class="line">675</span><br><span class="line">676</span><br><span class="line">677</span><br><span class="line">678</span><br><span class="line">679</span><br><span class="line">680</span><br><span class="line">681</span><br><span class="line">682</span><br><span class="line">683</span><br><span class="line">684</span><br><span class="line">685</span><br><span class="line">686</span><br><span class="line">687</span><br><span class="line">688</span><br><span class="line">689</span><br><span class="line">690</span><br><span class="line">691</span><br><span class="line">692</span><br><span class="line">693</span><br><span class="line">694</span><br><span class="line">695</span><br><span class="line">696</span><br><span class="line">697</span><br><span class="line">698</span><br><span class="line">699</span><br><span class="line">700</span><br><span class="line">701</span><br><span class="line">702</span><br><span class="line">703</span><br><span class="line">704</span><br><span class="line">705</span><br><span class="line">706</span><br><span class="line">707</span><br><span class="line">708</span><br><span class="line">709</span><br><span class="line">710</span><br><span class="line">711</span><br><span class="line">712</span><br><span class="line">713</span><br><span class="line">714</span><br><span class="line">715</span><br><span class="line">716</span><br><span class="line">717</span><br><span class="line">718</span><br><span class="line">719</span><br><span class="line">720</span><br><span class="line">721</span><br><span class="line">722</span><br><span class="line">723</span><br><span class="line">724</span><br><span class="line">725</span><br><span class="line">726</span><br><span class="line">727</span><br><span class="line">728</span><br><span class="line">729</span><br><span class="line">730</span><br><span class="line">731</span><br><span class="line">732</span><br><span class="line">733</span><br><span class="line">734</span><br><span class="line">735</span><br><span class="line">736</span><br><span class="line">737</span><br><span class="line">738</span><br><span class="line">739</span><br><span class="line">740</span><br><span class="line">741</span><br><span class="line">742</span><br><span class="line">743</span><br><span class="line">744</span><br><span class="line">745</span><br><span class="line">746</span><br><span class="line">747</span><br><span class="line">748</span><br><span class="line">749</span><br><span class="line">750</span><br><span class="line">751</span><br><span class="line">752</span><br><span class="line">753</span><br><span class="line">754</span><br><span class="line">755</span><br><span class="line">756</span><br><span class="line">757</span><br><span class="line">758</span><br><span class="line">759</span><br><span class="line">760</span><br><span class="line">761</span><br><span class="line">762</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* GStreamer</span></span><br><span class="line"><span class="comment"> * Copyright (C) gu.wen &lt;454727014@qq.com&gt;</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * gstqnxvideosink.c: </span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * SECTION:element-qnxvideosink</span></span><br><span class="line"><span class="comment"> * @see_also: #GstQnxVideoSink</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * Displays video on qnx.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * &lt;refsect2&gt;</span></span><br><span class="line"><span class="comment"> * &lt;title&gt;Example launch line&lt;/title&gt;</span></span><br><span class="line"><span class="comment"> * |[</span></span><br><span class="line"><span class="comment"> * gst-launch-1.0 filesrc location=test.avi ! decodebin ! videoconvert ! qnxvideosink</span></span><br><span class="line"><span class="comment"> * ]| This pipeline renders a video to ascii art into a separate window.</span></span><br><span class="line"><span class="comment"> * |[</span></span><br><span class="line"><span class="comment"> * gst-launch-1.0 filesrc location=test.avi ! decodebin ! videoconvert ! qnxvideosink driver=curses</span></span><br><span class="line"><span class="comment"> * ]| This pipeline renders a video to ascii art into the current terminal.</span></span><br><span class="line"><span class="comment"> * &lt;/refsect2&gt;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifdef</span> HAVE_CONFIG_H</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"config.h"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;sys/time.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;gst/video/gstvideometa.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"gstQnxVideoSink.h"</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">///////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">///////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> PLUGIN_VERSION <span class="meta-string">"00.01.00"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> PACKAGE <span class="meta-string">"gst-plugins-qnx"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_LICENSE <span class="meta-string">"LGPL"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_PACKAGE_NAME <span class="meta-string">"GStreamer qnx Plug-ins source release"</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_PACKAGE_ORIGIN <span class="meta-string">"Unknown package origin"</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_DEFAULT_FRAME_BUF_CNT 4</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_DISP_BUF_CNT 4</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_DISP_USAGE SCREEN_USAGE_NATIVE|SCREEN_USAGE_WRITE</span></span><br><span class="line"><span class="comment">/* qnxvideosink signals and args */</span></span><br><span class="line"><span class="keyword">enum</span></span><br><span class="line">&#123;</span><br><span class="line">    LAST_SIGNAL</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="keyword">enum</span></span><br><span class="line">&#123;</span><br><span class="line">    PROP_0,</span><br><span class="line">    PROP_WIDTH,</span><br><span class="line">    PROP_HEIGHT,</span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0</span></span><br><span class="line">    PROP_DRIVER,</span><br><span class="line">    PROP_DITHER,</span><br><span class="line">    PROP_BRIGHTNESS,</span><br><span class="line">    PROP_CONTRAST,</span><br><span class="line">    PROP_GAMMA,</span><br><span class="line">    PROP_INVERSION,</span><br><span class="line">    PROP_RANDOMVAL,</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">    PROP_FRAMES_DISPLAYED,</span><br><span class="line">    PROP_FRAME_TIME</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE(<span class="string">"sink"</span>,</span><br><span class="line">                                                                    GST_PAD_SINK,</span><br><span class="line">                                                                    GST_PAD_ALWAYS,</span><br><span class="line">                                                                    GST_STATIC_CAPS(GST_VIDEO_CAPS_MAKE(<span class="string">"NV12"</span>)));</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> GstCaps *<span class="title">gst_qnxvideo_sink_fixate</span><span class="params">(GstBaseSink *bsink, GstCaps *caps)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxvideo_sink_setcaps</span><span class="params">(GstBaseSink *bsink, GstCaps *caps)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxvideo_sink_get_times</span><span class="params">(GstBaseSink *bsink, GstBuffer *buffer,</span></span></span><br><span class="line"><span class="function"><span class="params">                                       GstClockTime *start, GstClockTime *end)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxvideo_sink_propose_allocation</span><span class="params">(GstBaseSink *bsink,</span></span></span><br><span class="line"><span class="function"><span class="params">                                                    GstQuery *query)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> GstFlowReturn <span class="title">gst_qnxvideo_sink_show_frame</span><span class="params">(GstVideoSink *videosink,</span></span></span><br><span class="line"><span class="function"><span class="params">                                                 GstBuffer *buffer)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxvideo_sink_set_property</span><span class="params">(GObject *object, guint prop_id,</span></span></span><br><span class="line"><span class="function"><span class="params">                                          <span class="keyword">const</span> GValue *value, GParamSpec *pspec)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxvideo_sink_get_property</span><span class="params">(GObject *object, guint prop_id,</span></span></span><br><span class="line"><span class="function"><span class="params">                                          GValue *value, GParamSpec *pspec)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> GstStateChangeReturn <span class="title">gst_qnxvideo_sink_change_state</span><span class="params">(GstElement *element,</span></span></span><br><span class="line"><span class="function"><span class="params">                                                          GstStateChange transition)</span></span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> gst_qnxvideo_sink_parent_class parent_class</span></span><br><span class="line">G_DEFINE_TYPE(GstQnxVideoSink, gst_qnxvideo_sink, GST_TYPE_VIDEO_SINK);</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_TYPE_QNXVIDEODRIVERS (gst_qnxvideo_sink_drivers_get_type())</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> GType <span class="title">gst_qnxvideo_sink_drivers_get_type</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">static</span> GType driver_type = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (!driver_type)</span><br><span class="line">    &#123;</span><br><span class="line">        GEnumValue *drivers;</span><br><span class="line">        <span class="keyword">const</span> <span class="class"><span class="keyword">struct</span> <span class="title">aa_driver</span> *<span class="title">driver</span>;</span></span><br><span class="line">        gint n_drivers;</span><br><span class="line">        gint i;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">for</span> (n_drivers = <span class="number">0</span>; aa_drivers[n_drivers]; n_drivers++)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="comment">/* count number of drivers */</span></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        drivers = g_new0(GEnumValue, n_drivers + <span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">for</span> (i = <span class="number">0</span>; i &lt; n_drivers; i++)</span><br><span class="line">        &#123;</span><br><span class="line">            driver = aa_drivers[i];</span><br><span class="line">            drivers[i].value = i;</span><br><span class="line">            drivers[i].value_name = g_strdup(driver-&gt;name);</span><br><span class="line">            drivers[i].value_nick = g_utf8_strdown(driver-&gt;shortname, <span class="number">-1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        drivers[i].value = <span class="number">0</span>;</span><br><span class="line">        drivers[i].value_name = <span class="literal">NULL</span>;</span><br><span class="line">        drivers[i].value_nick = <span class="literal">NULL</span>;</span><br><span class="line"></span><br><span class="line">        driver_type = g_enum_register_static(<span class="string">"GstQnxVideoSinkDrivers"</span>, drivers);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> driver_type;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> GST_TYPE_AADITHER (gst_qnxvideo_sink_dither_get_type())</span></span><br><span class="line"><span class="function"><span class="keyword">static</span> GType <span class="title">gst_qnxvideo_sink_dither_get_type</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">static</span> GType dither_type = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (!dither_type)</span><br><span class="line">    &#123;</span><br><span class="line">        GEnumValue *ditherers;</span><br><span class="line">        gint n_ditherers;</span><br><span class="line">        gint i;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">for</span> (n_ditherers = <span class="number">0</span>; aa_dithernames[n_ditherers]; n_ditherers++)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="comment">/* count number of ditherers */</span></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        ditherers = g_new0(GEnumValue, n_ditherers + <span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">for</span> (i = <span class="number">0</span>; i &lt; n_ditherers; i++)</span><br><span class="line">        &#123;</span><br><span class="line">            ditherers[i].value = i;</span><br><span class="line">            ditherers[i].value_name = g_strdup(aa_dithernames[i]);</span><br><span class="line">            ditherers[i].value_nick =</span><br><span class="line">                g_strdelimit(g_strdup(aa_dithernames[i]), <span class="string">" _"</span>, <span class="string">'-'</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        ditherers[i].value = <span class="number">0</span>;</span><br><span class="line">        ditherers[i].value_name = <span class="literal">NULL</span>;</span><br><span class="line">        ditherers[i].value_nick = <span class="literal">NULL</span>;</span><br><span class="line"></span><br><span class="line">        dither_type = g_enum_register_static(<span class="string">"GstQnxVideoSinkDitherers"</span>, ditherers);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> dither_type;</span><br><span class="line">&#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxvideo_sink_class_init</span><span class="params">(GstQnxVideoSinkClass *klass)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GObjectClass *gobject_class;</span><br><span class="line">    GstElementClass *gstelement_class;</span><br><span class="line">    GstBaseSinkClass *gstbasesink_class;</span><br><span class="line">    GstVideoSinkClass *gstvideosink_class;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    gobject_class = (GObjectClass *)klass;</span><br><span class="line">    gstelement_class = (GstElementClass *)klass;</span><br><span class="line">    gstbasesink_class = (GstBaseSinkClass *)klass;</span><br><span class="line">    gstvideosink_class = (GstVideoSinkClass *)klass;</span><br><span class="line"></span><br><span class="line">    gobject_class-&gt;set_property = gst_qnxvideo_sink_set_property;</span><br><span class="line">    gobject_class-&gt;get_property = gst_qnxvideo_sink_get_property;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* <span class="doctag">FIXME:</span> add long property descriptions */</span></span><br><span class="line">    g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_WIDTH,</span><br><span class="line">                                    g_param_spec_int(<span class="string">"width"</span>, <span class="string">"width"</span>, <span class="string">"width"</span>, G_MININT, G_MAXINT, <span class="number">0</span>,</span><br><span class="line">                                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line">    g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_HEIGHT,</span><br><span class="line">                                    g_param_spec_int(<span class="string">"height"</span>, <span class="string">"height"</span>, <span class="string">"height"</span>, G_MININT, G_MAXINT, <span class="number">0</span>,</span><br><span class="line">                                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0  </span></span><br><span class="line">  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DRIVER,</span><br><span class="line">      g_param_spec_enum (<span class="string">"driver"</span>, <span class="string">"driver"</span>, <span class="string">"driver"</span>, GST_TYPE_QNXVIDEODRIVERS, <span class="number">0</span>,</span><br><span class="line">          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line"></span><br><span class="line">  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DITHER,</span><br><span class="line">      g_param_spec_enum (<span class="string">"dither"</span>, <span class="string">"dither"</span>, <span class="string">"dither"</span>, GST_TYPE_AADITHER, <span class="number">0</span>,</span><br><span class="line">          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line">  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BRIGHTNESS,</span><br><span class="line">      g_param_spec_int (<span class="string">"brightness"</span>, <span class="string">"brightness"</span>, <span class="string">"brightness"</span>, G_MININT,</span><br><span class="line">          G_MAXINT, <span class="number">0</span>, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line">  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CONTRAST,</span><br><span class="line">      g_param_spec_int (<span class="string">"contrast"</span>, <span class="string">"contrast"</span>, <span class="string">"contrast"</span>, G_MININT, G_MAXINT,</span><br><span class="line">          <span class="number">0</span>, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line">  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_GAMMA,</span><br><span class="line">      g_param_spec_float (<span class="string">"gamma"</span>, <span class="string">"gamma"</span>, <span class="string">"gamma"</span>, <span class="number">0.0</span>, <span class="number">5.0</span>, <span class="number">1.0</span>,</span><br><span class="line">          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line">  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_INVERSION,</span><br><span class="line">      g_param_spec_boolean (<span class="string">"inversion"</span>, <span class="string">"inversion"</span>, <span class="string">"inversion"</span>, TRUE,</span><br><span class="line">          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line">  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_RANDOMVAL,</span><br><span class="line">      g_param_spec_int (<span class="string">"randomval"</span>, <span class="string">"randomval"</span>, <span class="string">"randomval"</span>, G_MININT,</span><br><span class="line">          G_MAXINT, <span class="number">0</span>, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));</span><br><span class="line"></span><br><span class="line">    g_object_class_install_property(G_OBJECT_CLASS(klass),</span><br><span class="line">                                    PROP_FRAMES_DISPLAYED, g_param_spec_int(<span class="string">"frames-displayed"</span>, <span class="string">"frames displayed"</span>, <span class="string">"frames displayed"</span>, G_MININT, G_MAXINT, <span class="number">0</span>, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));</span><br><span class="line">    g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_FRAME_TIME,</span><br><span class="line">                                    g_param_spec_int(<span class="string">"frame-time"</span>, <span class="string">"frame time"</span>, <span class="string">"frame time"</span>, G_MININT,</span><br><span class="line">                                                     G_MAXINT, <span class="number">0</span>, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">    gst_element_class_add_static_pad_template(gstelement_class, &amp;sink_template);</span><br><span class="line"></span><br><span class="line">    gst_element_class_set_static_metadata(gstelement_class,</span><br><span class="line">                                          <span class="string">"Qnx video sink"</span>, <span class="string">"Sink/Video"</span>, <span class="string">"An Qnx videosink"</span>,</span><br><span class="line">                                          <span class="string">"guwen &lt;454727014@qq.com&gt;"</span>);</span><br><span class="line"></span><br><span class="line">    gstelement_class-&gt;change_state = GST_DEBUG_FUNCPTR(gst_qnxvideo_sink_change_state);</span><br><span class="line"></span><br><span class="line">    gstbasesink_class-&gt;fixate = GST_DEBUG_FUNCPTR(gst_qnxvideo_sink_fixate);</span><br><span class="line">    gstbasesink_class-&gt;set_caps = GST_DEBUG_FUNCPTR(gst_qnxvideo_sink_setcaps);</span><br><span class="line">    gstbasesink_class-&gt;get_times = GST_DEBUG_FUNCPTR(gst_qnxvideo_sink_get_times);</span><br><span class="line">    gstbasesink_class-&gt;propose_allocation =</span><br><span class="line">        GST_DEBUG_FUNCPTR(gst_qnxvideo_sink_propose_allocation);</span><br><span class="line"></span><br><span class="line">    gstvideosink_class-&gt;show_frame = GST_DEBUG_FUNCPTR(gst_qnxvideo_sink_show_frame);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> GstCaps* <span class="title">gst_qnxvideo_sink_fixate</span><span class="params">(GstBaseSink *bsink, GstCaps *caps)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GstStructure *structure;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    caps = gst_caps_make_writable(caps);</span><br><span class="line"></span><br><span class="line">    structure = gst_caps_get_structure(caps, <span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">    gst_structure_fixate_field_nearest_int(structure, <span class="string">"width"</span>, <span class="number">1920</span>);</span><br><span class="line">    gst_structure_fixate_field_nearest_int(structure, <span class="string">"height"</span>, <span class="number">720</span>);</span><br><span class="line">    gst_structure_fixate_field_nearest_fraction(structure, <span class="string">"framerate"</span>, <span class="number">30</span>, <span class="number">1</span>);</span><br><span class="line"></span><br><span class="line">    caps = GST_BASE_SINK_CLASS(parent_class)-&gt;fixate(bsink, caps);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:caps: %p\n"</span>, __FUNCTION__, __LINE__, caps);</span><br><span class="line">    <span class="keyword">return</span> caps;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxvideo_sink_setcaps</span><span class="params">(GstBaseSink *basesink, GstCaps *caps)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GstQnxVideoSink *qnxvideosink;</span><br><span class="line">    GstVideoInfo info;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    qnxvideosink = GST_QNXVIDEOSINK(basesink);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (!gst_video_info_from_caps(&amp;info, caps))</span><br><span class="line">        <span class="keyword">goto</span> invalid_caps;</span><br><span class="line"></span><br><span class="line">    qnxvideosink-&gt;info = info;</span><br><span class="line">    qnxvideosink-&gt;width = info.width;</span><br><span class="line">    qnxvideosink-&gt;height = info.height;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:witdh: %d, height:%d\n"</span>, </span><br><span class="line">           __FUNCTION__, __LINE__, info.width, info.height);</span><br><span class="line">           </span><br><span class="line">    <span class="keyword">if</span> (qnxvideosink-&gt;screen_win)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">memset</span>(&amp;(qnxvideosink-&gt;dispRect), <span class="number">0</span>, <span class="keyword">sizeof</span>(qnxvideosink-&gt;dispRect));</span><br><span class="line">        qnxvideosink-&gt;dispRect[<span class="number">2</span>] = qnxvideosink-&gt;width;</span><br><span class="line">        qnxvideosink-&gt;dispRect[<span class="number">3</span>] = qnxvideosink-&gt;height;</span><br><span class="line">        screen_create_window_buffers(qnxvideosink-&gt;screen_win, GST_DISP_BUF_CNT);</span><br><span class="line">        </span><br><span class="line">        <span class="comment">//screen_get_window_property_iv(qnxvideosink-&gt;screen_win,</span></span><br><span class="line">        <span class="comment">//                              SCREEN_PROPERTY_BUFFER_SIZE,</span></span><br><span class="line">        <span class="comment">//                              qnxvideosink-&gt;dispRect + 2);</span></span><br><span class="line">        screen_set_window_property_iv(qnxvideosink-&gt;screen_win, </span><br><span class="line">                                      SCREEN_PROPERTY_SIZE, </span><br><span class="line">                                      qnxvideosink-&gt;dispRect + <span class="number">2</span>);</span><br><span class="line"></span><br><span class="line">        screen_set_window_property_iv(qnxvideosink-&gt;screen_win, </span><br><span class="line">                                      SCREEN_PROPERTY_BUFFER_SIZE, </span><br><span class="line">                                      qnxvideosink-&gt;dispRect + <span class="number">2</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> TRUE;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* ERRORS */</span></span><br><span class="line">invalid_caps:</span><br><span class="line">&#123;</span><br><span class="line">    GST_ERROR_OBJECT(qnxvideosink, <span class="string">"invalid caps"</span>);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> FALSE;</span><br><span class="line">&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> <span class="keyword">void</span></span><br><span class="line">gst_qnxvideo_sink_init(GstQnxVideoSink *qnxvideosink)</span><br><span class="line">&#123;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0    </span></span><br><span class="line">    <span class="built_in">memcpy</span>(&amp;qnxvideosink-&gt;ascii_surf, &amp;aa_defparams,</span><br><span class="line">           <span class="keyword">sizeof</span>(struct aa_hardware_params));</span><br><span class="line"></span><br><span class="line">    qnxvideosink-&gt;ascii_parms.bright = <span class="number">0</span>;</span><br><span class="line">    qnxvideosink-&gt;ascii_parms.contrast = <span class="number">16</span>;</span><br><span class="line">    qnxvideosink-&gt;ascii_parms.gamma = <span class="number">1.0</span>;</span><br><span class="line">    qnxvideosink-&gt;ascii_parms.dither = <span class="number">0</span>;</span><br><span class="line">    qnxvideosink-&gt;ascii_parms.inversion = <span class="number">0</span>;</span><br><span class="line">    qnxvideosink-&gt;ascii_parms.randomval = <span class="number">0</span>;</span><br><span class="line">    qnxvideosink-&gt;aa_driver = <span class="number">0</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span></span></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    qnxvideosink-&gt;screen_win = <span class="literal">NULL</span>;</span><br><span class="line">    qnxvideosink-&gt;screen_ctx = <span class="literal">NULL</span>;</span><br><span class="line">    qnxvideosink-&gt;isOpened = FALSE;</span><br><span class="line">    <span class="built_in">memset</span>(&amp;(qnxvideosink-&gt;dispRect), <span class="number">0</span>, <span class="keyword">sizeof</span>(qnxvideosink-&gt;dispRect));</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">gst_qnxvideo_sink_scale</span><span class="params">(GstQnxVideoSink *qnxvideosink, guchar *src, guchar *dest,</span></span></span><br><span class="line"><span class="function"><span class="params">                       gint sw, gint sh, gint ss, gint dw, gint dh)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    gint ypos, yinc, y;</span><br><span class="line">    gint xpos, xinc, x;</span><br><span class="line"></span><br><span class="line">    g_return_if_fail((dw != <span class="number">0</span>) &amp;&amp; (dh != <span class="number">0</span>));</span><br><span class="line"></span><br><span class="line">    ypos = <span class="number">0x10000</span>;</span><br><span class="line">    yinc = (sh &lt;&lt; <span class="number">16</span>) / dh;</span><br><span class="line">    xinc = (sw &lt;&lt; <span class="number">16</span>) / dw;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span> (y = dh; y; y--)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="keyword">while</span> (ypos &gt; <span class="number">0x10000</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            ypos -= <span class="number">0x10000</span>;</span><br><span class="line">            src += ss;</span><br><span class="line">        &#125;</span><br><span class="line">        xpos = <span class="number">0x10000</span>;</span><br><span class="line">        &#123;</span><br><span class="line">            guchar *destp = dest;</span><br><span class="line">            guchar *srcp = src;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">for</span> (x = dw; x; x--)</span><br><span class="line">            &#123;</span><br><span class="line">                <span class="keyword">while</span> (xpos &gt;= <span class="number">0x10000</span>L)</span><br><span class="line">                &#123;</span><br><span class="line">                    srcp++;</span><br><span class="line">                    xpos -= <span class="number">0x10000</span>L;</span><br><span class="line">                &#125;</span><br><span class="line">                *destp++ = *srcp;</span><br><span class="line">                xpos += xinc;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        dest += dw;</span><br><span class="line">        ypos += yinc;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> <span class="keyword">void</span></span><br><span class="line">gst_qnxvideo_sink_get_times(GstBaseSink *sink, GstBuffer *buffer,</span><br><span class="line">                           GstClockTime *start, GstClockTime *end)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="comment">//printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    *start = GST_BUFFER_TIMESTAMP(buffer);</span><br><span class="line">    <span class="keyword">if</span> (GST_BUFFER_DURATION_IS_VALID(buffer))</span><br><span class="line">        *end = *start + GST_BUFFER_DURATION(buffer);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxvideo_sink_propose_allocation</span><span class="params">(GstBaseSink *bsink, GstQuery *query)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GstCaps *caps;</span><br><span class="line">    GstVideoInfo info;</span><br><span class="line">    guint size;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    gst_query_parse_allocation(query, &amp;caps, <span class="literal">NULL</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (caps == <span class="literal">NULL</span>)</span><br><span class="line">        <span class="keyword">goto</span> no_caps;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (!gst_video_info_from_caps(&amp;info, caps))</span><br><span class="line">        <span class="keyword">goto</span> invalid_caps;</span><br><span class="line"></span><br><span class="line">    size = GST_VIDEO_INFO_SIZE(&amp;info);</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* we need at least 2 buffer because we hold on to the last one */</span></span><br><span class="line">    gst_query_add_allocation_pool(query, <span class="literal">NULL</span>, size, GST_DEFAULT_FRAME_BUF_CNT, <span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* we support various metadata */</span></span><br><span class="line">    gst_query_add_allocation_meta(query, GST_VIDEO_META_API_TYPE, <span class="literal">NULL</span>);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> TRUE;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* ERRORS */</span></span><br><span class="line">no_caps:</span><br><span class="line">&#123;</span><br><span class="line">    GST_ERROR_OBJECT(bsink, <span class="string">"no caps specified"</span>);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> FALSE;</span><br><span class="line">&#125;</span><br><span class="line">invalid_caps:</span><br><span class="line">&#123;</span><br><span class="line">    GST_ERROR_OBJECT(bsink, <span class="string">"invalid caps specified"</span>);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> FALSE;</span><br><span class="line">&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> GstFlowReturn <span class="title">gst_qnxvideo_sink_show_frame</span><span class="params">(GstVideoSink *videosink, GstBuffer *buffer)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    GstQnxVideoSink *qnxvideosink;</span><br><span class="line">    GstVideoFrame frame;</span><br><span class="line">  <span class="comment">//  printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    qnxvideosink = GST_QNXVIDEOSINK(videosink);</span><br><span class="line"></span><br><span class="line">    GST_DEBUG(<span class="string">"show frame"</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (!gst_video_frame_map(&amp;frame, &amp;qnxvideosink-&gt;info, buffer, GST_MAP_READ))</span><br><span class="line">        <span class="keyword">goto</span> invalid_frame;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0</span></span><br><span class="line">    <span class="keyword">screen_pixmap_t</span> pixmapInfo;</span><br><span class="line">	screen_create_pixmap(&amp;pixmapInfo, qnxvideosink-&gt;screen_ctx);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">int</span> format = SCREEN_FORMAT_NV12;</span><br><span class="line">	screen_set_pixmap_property_iv(pixmapInfo, SCREEN_PROPERTY_FORMAT, &amp;format);</span><br><span class="line"></span><br><span class="line">	gint usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE;</span><br><span class="line">	screen_set_pixmap_property_iv(pixmapInfo, SCREEN_PROPERTY_USAGE, &amp;usage);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">int</span> size[<span class="number">2</span>] = &#123; qnxvideosink-&gt;width, qnxvideosink-&gt;height &#125;;</span><br><span class="line">	screen_set_pixmap_property_iv(pixmapInfo, SCREEN_PROPERTY_BUFFER_SIZE, size);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">screen_buffer_t</span> pixmapBuf;</span><br><span class="line">	screen_create_pixmap_buffer(pixmapInfo);</span><br><span class="line">	screen_get_pixmap_property_pv(pixmapInfo, SCREEN_PROPERTY_RENDER_BUFFERS, (<span class="keyword">void</span> **)&amp;pixmapBuf);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">unsigned</span> <span class="keyword">char</span> *pBuf = <span class="literal">NULL</span>;</span><br><span class="line">	screen_get_buffer_property_pv(pixmapBuf, SCREEN_PROPERTY_POINTER, (<span class="keyword">void</span> **)&amp;pBuf);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">int</span> stride = <span class="number">0</span>;</span><br><span class="line">	screen_get_buffer_property_iv(pixmapBuf, SCREEN_PROPERTY_STRIDE, &amp;stride);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0</span></span><br><span class="line">	<span class="keyword">for</span> (i = <span class="number">0</span>; i &lt; size[<span class="number">1</span>]; i++, ptr += stride) &#123;</span><br><span class="line">			<span class="keyword">for</span> (j = <span class="number">0</span>; j &lt; size[<span class="number">0</span>]; j++) &#123;</span><br><span class="line">				ptr[j*<span class="number">4</span>] = <span class="number">0xa0</span>;</span><br><span class="line">				ptr[j*<span class="number">4</span>+<span class="number">1</span>] = <span class="number">0xa0</span>;</span><br><span class="line">				ptr[j*<span class="number">4</span>+<span class="number">2</span>] = <span class="number">0xa0</span>;</span><br><span class="line">				ptr[j*<span class="number">4</span>+<span class="number">3</span>] = ((j &gt;= i &amp;&amp; j &lt;= size[<span class="number">1</span>]-i) || (j &lt;= i &amp;&amp; j &gt;= size[<span class="number">1</span>]-i)) ? <span class="number">0xff</span> : <span class="number">0</span>;</span><br><span class="line">			&#125;</span><br><span class="line">	&#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0</span></span><br><span class="line">    gst_qnxvideo_sink_scale(qnxvideosink, GST_VIDEO_FRAME_PLANE_DATA(&amp;frame, <span class="number">0</span>), <span class="comment">/* src */</span></span><br><span class="line">                           pBuf,                     <span class="comment">/* dest */</span></span><br><span class="line">                           GST_VIDEO_INFO_WIDTH(&amp;qnxvideosink-&gt;info),           <span class="comment">/* sw */</span></span><br><span class="line">                           GST_VIDEO_INFO_HEIGHT(&amp;qnxvideosink-&gt;info),          <span class="comment">/* sh */</span></span><br><span class="line">                           GST_VIDEO_FRAME_PLANE_STRIDE(&amp;frame, <span class="number">0</span>),             <span class="comment">/* ss */</span></span><br><span class="line">                           qnxvideosink-&gt;width,                  <span class="comment">/* dw */</span></span><br><span class="line">                           qnxvideosink-&gt;height);                <span class="comment">/* dh */</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span></span></span><br><span class="line">    <span class="built_in">memcpy</span>(pBuf, GST_VIDEO_FRAME_PLANE_DATA(&amp;frame, <span class="number">0</span>), qnxvideosink-&gt;width * qnxvideosink-&gt;height * <span class="number">3</span> / <span class="number">2</span>);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">	<span class="keyword">screen_buffer_t</span> render_buf[<span class="number">2</span>];</span><br><span class="line">    screen_get_window_property_pv(qnxvideosink-&gt;screen_win, </span><br><span class="line">                                 SCREEN_PROPERTY_RENDER_BUFFERS, (<span class="keyword">void</span> **)render_buf);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">int</span> hg[] = &#123;</span><br><span class="line">        SCREEN_BLIT_SOURCE_WIDTH, qnxvideosink-&gt;width,</span><br><span class="line">        SCREEN_BLIT_SOURCE_HEIGHT, qnxvideosink-&gt;height,</span><br><span class="line">        SCREEN_BLIT_DESTINATION_X, <span class="number">0</span>,</span><br><span class="line">        SCREEN_BLIT_DESTINATION_Y, <span class="number">0</span>,</span><br><span class="line">        SCREEN_BLIT_DESTINATION_WIDTH, qnxvideosink-&gt;width,</span><br><span class="line">        SCREEN_BLIT_DESTINATION_HEIGHT, qnxvideosink-&gt;height,</span><br><span class="line">        SCREEN_BLIT_TRANSPARENCY, SCREEN_TRANSPARENCY_SOURCE_OVER,</span><br><span class="line">        SCREEN_BLIT_END</span><br><span class="line">    &#125;;</span><br><span class="line"></span><br><span class="line">    screen_blit(qnxvideosink-&gt;screen_ctx, render_buf[<span class="number">0</span>], pixmapBuf, hg);</span><br><span class="line"></span><br><span class="line">    screen_post_window(qnxvideosink-&gt;screen_win, render_buf[<span class="number">0</span>], <span class="number">1</span>, qnxvideosink-&gt;dispRect, <span class="number">0</span>);    </span><br><span class="line"></span><br><span class="line">    screen_destroy_pixmap(pixmapInfo);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span></span></span><br><span class="line">    <span class="keyword">screen_buffer_t</span> render_buf[GST_DISP_BUF_CNT];</span><br><span class="line">    screen_get_window_property_pv(qnxvideosink-&gt;screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (<span class="keyword">void</span> **)&amp;render_buf);   </span><br><span class="line"></span><br><span class="line">    <span class="keyword">char</span> *pBuf = <span class="literal">NULL</span>;</span><br><span class="line">	screen_get_buffer_property_pv(render_buf[<span class="number">0</span>], SCREEN_PROPERTY_POINTER, (<span class="keyword">void</span> **)&amp;pBuf); </span><br><span class="line">    <span class="built_in">memcpy</span>(pBuf, GST_VIDEO_FRAME_PLANE_DATA(&amp;frame, <span class="number">0</span>), qnxvideosink-&gt;width * qnxvideosink-&gt;height * <span class="number">3</span> / <span class="number">2</span>);</span><br><span class="line"></span><br><span class="line">    screen_post_window(qnxvideosink-&gt;screen_win, render_buf[<span class="number">0</span>], <span class="number">1</span>, qnxvideosink-&gt;dispRect, <span class="number">0</span>);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line">    gst_video_frame_unmap(&amp;frame);</span><br><span class="line">    qnxvideosink-&gt;frames_displayed++;</span><br><span class="line">  <span class="comment">//  printf("[%s.%d]===&gt;:\n", __FUNCTION__, __LINE__);</span></span><br><span class="line">    <span class="keyword">return</span> GST_FLOW_OK;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* ERRORS */</span></span><br><span class="line">invalid_frame:</span><br><span class="line">&#123;</span><br><span class="line">    GST_ERROR_OBJECT(qnxvideosink, <span class="string">"invalid frame"</span>);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> GST_FLOW_ERROR;</span><br><span class="line">&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> <span class="keyword">void</span></span><br><span class="line">gst_qnxvideo_sink_set_property(GObject *object, guint prop_id, <span class="keyword">const</span> GValue *value,</span><br><span class="line">                              GParamSpec *pspec)</span><br><span class="line">&#123;</span><br><span class="line">    GstQnxVideoSink *qnxvideosink;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;: prop_id:%d\n"</span>, __FUNCTION__, __LINE__, prop_id);</span><br><span class="line">    qnxvideosink = GST_QNXVIDEOSINK(object);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">switch</span> (prop_id)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> PROP_WIDTH:</span><br><span class="line">        qnxvideosink-&gt;width = g_value_get_int(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> PROP_HEIGHT:</span><br><span class="line">        qnxvideosink-&gt;height = g_value_get_int(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0</span></span><br><span class="line">    <span class="keyword">case</span> PROP_DRIVER:</span><br><span class="line">    &#123;</span><br><span class="line">        qnxvideosink-&gt;aa_driver = g_value_get_enum(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_DITHER:</span><br><span class="line">    &#123;</span><br><span class="line">        qnxvideosink-&gt;ascii_parms.dither = g_value_get_enum(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_BRIGHTNESS:</span><br><span class="line">    &#123;</span><br><span class="line">        qnxvideosink-&gt;ascii_parms.bright = g_value_get_int(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_CONTRAST:</span><br><span class="line">    &#123;</span><br><span class="line">        qnxvideosink-&gt;ascii_parms.contrast = g_value_get_int(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_GAMMA:</span><br><span class="line">    &#123;</span><br><span class="line">        qnxvideosink-&gt;ascii_parms.gamma = g_value_get_float(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_INVERSION:</span><br><span class="line">    &#123;</span><br><span class="line">        qnxvideosink-&gt;ascii_parms.inversion = g_value_get_boolean(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_RANDOMVAL:</span><br><span class="line">    &#123;</span><br><span class="line">        qnxvideosink-&gt;ascii_parms.randomval = g_value_get_int(value);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">    <span class="keyword">default</span>:</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> <span class="keyword">void</span></span><br><span class="line">gst_qnxvideo_sink_get_property(GObject *object, guint prop_id, GValue *value,</span><br><span class="line">                              GParamSpec *pspec)</span><br><span class="line">&#123;</span><br><span class="line">    GstQnxVideoSink *qnxvideosink;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:, prop_id: %d\n"</span>, __FUNCTION__, __LINE__, prop_id);</span><br><span class="line">    qnxvideosink = GST_QNXVIDEOSINK(object);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">switch</span> (prop_id)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> PROP_WIDTH:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_int(value, qnxvideosink-&gt;width);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_HEIGHT:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_int(value, qnxvideosink-&gt;height);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> 0</span></span><br><span class="line">    <span class="keyword">case</span> PROP_DRIVER:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_enum(value, qnxvideosink-&gt;aa_driver);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_DITHER:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_enum(value, qnxvideosink-&gt;ascii_parms.dither);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_BRIGHTNESS:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_int(value, qnxvideosink-&gt;ascii_parms.bright);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_CONTRAST:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_int(value, qnxvideosink-&gt;ascii_parms.contrast);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_GAMMA:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_float(value, qnxvideosink-&gt;ascii_parms.gamma);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_INVERSION:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_boolean(value, qnxvideosink-&gt;ascii_parms.inversion);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_RANDOMVAL:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_int(value, qnxvideosink-&gt;ascii_parms.randomval);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_FRAMES_DISPLAYED:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_int(value, qnxvideosink-&gt;frames_displayed);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">case</span> PROP_FRAME_TIME:</span><br><span class="line">    &#123;</span><br><span class="line">        g_value_set_int(value, qnxvideosink-&gt;frame_time / <span class="number">1000000</span>);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">    <span class="keyword">default</span>:</span><br><span class="line">    &#123;</span><br><span class="line">        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> gboolean</span><br><span class="line">gst_qnxvideo_sink_open(GstQnxVideoSink *qnxvideosink)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">if</span> (qnxvideosink-&gt;isOpened == FALSE)</span><br><span class="line">    &#123;</span><br><span class="line">        screen_create_context(&amp;qnxvideosink-&gt;screen_ctx, SCREEN_APPLICATION_CONTEXT);</span><br><span class="line">        screen_create_window(&amp;qnxvideosink-&gt;screen_win, qnxvideosink-&gt;screen_ctx);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">int</span> usage = GST_DISP_USAGE;</span><br><span class="line">        screen_set_window_property_iv(qnxvideosink-&gt;screen_win, SCREEN_PROPERTY_USAGE, &amp;usage);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">int</span> format = SCREEN_FORMAT_NV12;</span><br><span class="line">        screen_set_window_property_iv(qnxvideosink-&gt;screen_win, SCREEN_PROPERTY_FORMAT, &amp;format);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        qnxvideosink-&gt;isOpened = TRUE;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">        <span class="keyword">return</span> TRUE;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> FALSE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">gst_qnxvideo_sink_close</span><span class="params">(GstQnxVideoSink *qnxvideosink)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">if</span> (qnxvideosink-&gt;isOpened == TRUE)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="keyword">if</span> (qnxvideosink-&gt;screen_win)</span><br><span class="line">        &#123;</span><br><span class="line">            screen_destroy_window(qnxvideosink-&gt;screen_win);</span><br><span class="line">            qnxvideosink-&gt;screen_win = <span class="literal">NULL</span>;</span><br><span class="line">        &#125;    </span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> (qnxvideosink-&gt;screen_ctx)</span><br><span class="line">        &#123;</span><br><span class="line">            screen_destroy_context(qnxvideosink-&gt;screen_ctx);</span><br><span class="line">            qnxvideosink-&gt;screen_ctx = <span class="literal">NULL</span>;    </span><br><span class="line">        &#125;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">        <span class="keyword">return</span> TRUE;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> FALSE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">static</span> GstStateChangeReturn</span><br><span class="line">gst_qnxvideo_sink_change_state(GstElement *element, GstStateChange transition)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    GstStateChangeReturn ret;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">switch</span> (transition)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> GST_STATE_CHANGE_NULL_TO_READY:</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> GST_STATE_CHANGE_READY_TO_PAUSED:</span><br><span class="line">        <span class="keyword">if</span> (!gst_qnxvideo_sink_open(GST_QNXVIDEOSINK(element)))</span><br><span class="line">            <span class="keyword">goto</span> open_failed;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> GST_STATE_CHANGE_PAUSED_TO_PLAYING:</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">default</span>:</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    ret = GST_ELEMENT_CLASS(parent_class)-&gt;change_state(element, transition);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">switch</span> (transition)</span><br><span class="line">    &#123;</span><br><span class="line">    <span class="keyword">case</span> GST_STATE_CHANGE_PLAYING_TO_PAUSED:</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> GST_STATE_CHANGE_PAUSED_TO_READY:</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">case</span> GST_STATE_CHANGE_READY_TO_NULL:</span><br><span class="line">        gst_qnxvideo_sink_close(GST_QNXVIDEOSINK(element));</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    <span class="keyword">default</span>:</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> ret;</span><br><span class="line"></span><br><span class="line">open_failed:</span><br><span class="line">&#123;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> GST_STATE_CHANGE_FAILURE;</span><br><span class="line">&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> gboolean <span class="title">plugin_init</span><span class="params">(GstPlugin *plugin)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">if</span> (!gst_element_register(plugin, <span class="string">"qnxvideosink"</span>, GST_RANK_SECONDARY, GST_TYPE_QNXVIDEOSINK))</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">        <span class="keyword">return</span> FALSE;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">"[%s.%d]===&gt;:\n"</span>, __FUNCTION__, __LINE__);</span><br><span class="line">    <span class="keyword">return</span> TRUE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,</span><br><span class="line">                  GST_VERSION_MINOR,</span><br><span class="line">                  qnxvideo,</span><br><span class="line">                  <span class="string">"Qnx video sink"</span>,</span><br><span class="line">                  plugin_init, PLUGIN_VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);</span><br></pre></td></tr></table></figure>
<blockquote>
<p><font color="red">注意</font>， 输出的plugin动态库名称以 <a href="http://libpluginname.so" target="_blank" rel="noopener">libpluginname.so</a>  的形式， 而这个pluginname就是 编写插件时，定义插件的宏GST_PLUGIN_DEFINE 的参数中的name， 如果不匹配，就会出现插件无法是使用，被gstreamer将插件加入黑名单</p>
</blockquote>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/posts/30680.html">gstreamer移植qnx(五)：编写audio sink和video sink插件</a></p>
        <p><span>文章作者:</span><a href="/" title="回到主页">古 文</a></p>
        <p><span>发布时间:</span>2020-02-20, 15:10:12</p>
        <p><span>最后更新:</span>2020-02-21, 14:59:08</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/posts/30680.html" title="gstreamer移植qnx(五)：编写audio sink和video sink插件">http://xuanwolanxue.gitee.io/posts/30680.html</a>
            <span class="copy-path" data-clipboard-text="原文: http://xuanwolanxue.gitee.io/posts/30680.html　　作者: 古 文" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target="_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/posts/28659.html">
                    gstreamer移植qnx(四)：编译gstreamer插件
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/posts/4138.html">
                    gstreamer移植qnx(一)：概览篇
                </a>
            </div>
        
    </nav>

  
  
    
    <div style="padding: 0; margin: 20px auto; width: 90%; text-align: center;">
      <br>
      <div>有钱的捧个钱场，1元2元1毛2毛都行，您的支持将鼓励我继续创作！</div>
      <br>
      <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
        <div class="btn btn-pay">打赏支持</div>
      </button>
      <br>
      <br>
      <div id="QR" style="display: none;">
        
          <div id="wechat" style="display: inline-block;">
            <img id="wechat_qr" src="/img/wechat-reward-qr.png" alt="古 文 WeChat Pay">
            <p>微信打赏</p>
          </div>
        
        
          <div id="alipay" style="display: inline-block">
            <img id="alipay_qr" src="/img/alipay-reward-qr.png" alt="古 文 Alipay">
            <p>支付宝打赏</p>
          </div>
        
        <br>
        <br>
      </div>
    </div>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">1.</span> <span class="toc-text">一、概述</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">2.</span> <span class="toc-text">二、实现QNX audio sink插件</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">3.</span> <span class="toc-text">三、 实现QNX video sink 插件</span></a></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-6 i,
        .toc-level-6 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录" title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"gstreamer移植qnx(五)：编写audio sink和video sink插件　| 同好斋　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    
		<section id="comments" style="margin: 2em; padding: 2em; background: rgba(255, 255, 255, 0.5)">
    <div id="vcomment" class="comment"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src="//unpkg.com/valine@1.2.0-beta1/dist/Valine.min.js"></script>
    <script>
      new Valine({
        el: '#vcomment',
        notify: 'true',
        verify: 'true',
        app_id: "jGY8jU1Gd1LKJ1meqfpUrpfp-gzGzoHsz",
        app_key: "LnXY7e40Vnir0zsqU62K1MNA",
        placeholder: "评论",
        avatar: "mp"
      });
    </script>
</section>
	
	




    <div class="scroll" id="post-nav-button">
        
            <a href="/posts/28659.html" title="上一篇: gstreamer移植qnx(四)：编译gstreamer插件">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/posts/4138.html" title="下一篇: gstreamer移植qnx(一)：概览篇">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/posts/64143.html">repo安装与简单使用</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/4046.html">gstreamer移植qnx(三)：libgstreamer 移植</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/50488.html">gstreamer移植qnx(二)：移植glib2.6.3</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/28659.html">gstreamer移植qnx(四)：编译gstreamer插件</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/30680.html">gstreamer移植qnx(五)：编写audio sink和video sink插件</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/4138.html">gstreamer移植qnx(一)：概览篇</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/3250.html">c印记</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/56107.html">因为爱情</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2018-2020 古 文
                <br><br>
                <br>同好斋小网站<br>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_uv">
                      您是第 <span id="busuanzi_value_site_uv"></span> 位小伙伴
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_site_pv">
                        本站总访问量 <span id="busuanzi_value_site_pv"></span> 次
                    </span>
                
                <span>| </span>
                <span class="post-count">  已经写了 14.2k 字啦</span>
            </div>
        
        <br>
        <span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span>
        <script>
            var now = new Date(); 
            function createtime(){ var grt= new Date("12/19/2018 12:49:00");//此处修改你的建站时间或者网站上线时间 
            now.setTime(now.getTime()+250); 
            days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days); 
            hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours); 
            if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum); 
            mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;} 
            seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum); 
            snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;} 
            document.getElementById("timeDate").innerHTML = "本站已安全运行 "+dnum+" 天 "; 
            document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒"; } 
            setInterval("createtime()",250);
        </script>
        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 5;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





    <script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        $("a[target=_blank]").removeAttr("target");
    
</script>

    <script>
        var originTitle = document.title;
        var titleTime;
        document.addEventListener("visibilitychange", function() {
            if (document.hidden) {
                document.title = "(つェ⊂) 我藏好了哦~ " + originTitle;
                clearTimeout(titleTime);
            }
            else {
                document.title = "(*´∇｀*) 被你发现啦~ " + originTitle;
                titleTime = setTimeout(function() {
                    document.title = originTitle;
                }, 2000);
            }
        })
    </script>




	<script type="text/javascript" src="/resources/love.js"></script>
	<script type="text/javascript" src="/resources/float.js"></script>
	<script type="text/javascript" src="/resources/typewriter.js"></script>
	<script type="text/javascript" color="0,104,183" opacity="1" zindex="-1" count="50" src="/resources/particle.js"></script>


  </div>
<script src="/live2dw/lib/L2Dwidget.min.js?0c58a1486de42ac6cc1c59c7d98ae887"></script><script>L2Dwidget.init({"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/live2dw/assets/wanko.model.json"},"display":{"superSample":2,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-100},"mobile":{"show":false},"react":{"opacityDefault":0.5,"opacityOnHover":0.2},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>